![]() |
Function not working - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Function not working (/thread-22011.html) |
Function not working - eglaud - Oct-24-2019 Hello, I am creating code that will allow the user to (manually) paste a list of excel cells and return a list that lacks quotation marks and duplicates. I have been wanting to do this on my own, and created code that does this - the only issue is that it's not yet a function, so not very easy to repeat. My code below is having trouble working as a function, when I run the program is skips to the second >>> and when I input my list it selects the second word of the first line, telling me "invalid syntax". I type "halp():" (the function name)and it tells me "invalid syntax", highlighting the colon. Where am I going wrong? Below is my code, and the list of fish species I am using as an input BLACKNOSE DACE BLUE RIDGE SCULPIN BLUEGILL CREEK CHUB GREEN SUNFISH POTOMAC SCULPIN REDBREAST SUNFISH ROSYSIDE DACE WHITE SUCKER BLACKNOSE DACE BLUE RIDGE SCULPIN BLUEGILL CENTRAL STONEROLLER CREEK CHUB FANTAIL DARTER GREEN SUNFISH POTOMAC SCULPIN PUMPKINSEED ROSYSIDE DACE WHITE SUCKER from collections import OrderedDict #gives us a tool to order the list we create def halp() : Fish = raw_input("Paste excel data: ") #lets us input our fish species Fi = Fish.split("\n") #creates a list based off our fish species Fi = list (OrderedDict.fromkeys(Fi)) #removes duplicates print '[%s]' % ', '.join(map(str, Fi)) #removes quotation marks and prints list I'm not sure what changed, but it's suddenly working! |