Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function not working
#1
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked kindly support with this dropna function not working gheevarpaulosejobs 2 662 Jul-24-2023, 03:41 PM
Last Post: deanhystad
Exclamation Function Not Working Alivegamer 7 1,864 Jul-19-2022, 01:03 PM
Last Post: deanhystad
  try function working on PC but not raspberry pi AnotherSam 1 1,527 Oct-11-2021, 04:51 AM
Last Post: bowlofred
  Input() function not working in VS Code darpInd 7 13,281 Feb-17-2020, 03:28 PM
Last Post: snippsat
  Unrelated new function causing existing working function to fail Nick_G 2 2,248 Jan-27-2020, 07:21 PM
Last Post: Nick_G
  User Defined function not working Raj_Kumar 4 2,999 Dec-17-2019, 12:44 PM
Last Post: buran
  Invoking function in if else statement, not working! ibaad1406 13 5,597 May-30-2019, 09:05 PM
Last Post: ibaad1406
  function not working tryingtolearnpython 2 2,958 Jul-23-2018, 02:54 AM
Last Post: tryingtolearnpython
  function for SQLite query not working pythonNoob 1 2,792 May-16-2018, 05:21 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020