Nov-19-2019, 06:38 PM
Hello, I am creating a code that allows the user to paste copied excel cells into a function that will return all the entries with commas, properly capitalized, and without duplicates. My code is below (minus the part that fixes capitalization). I noticed with the way it is, if I type "blacknose dace, blacknose dace" it will still return both. If I paste the excel cells multiple times, it will also fail to remove duplicates. I am a very novice coder and am not sure what to do, any tips?
from collections import OrderedDict #gives us a tool to order the list we create print ("Type 'I()' to start the historic fish tool. Type 'stop' to end the loop") #instructions print ("Note: please PASTE the excel data. You may type it, but commas won't be placed.") def I(): #When we type "I()" the historic fish tool runs, letting us paste excel data to get a non-duplicated, #properly capitalized fish species list Fish = "Hi" #just defines the Fish variable so we may start the loop below while Fish != "STOP": #unless you type "stop" in any capitalization, this code will loop, letting the user #put in multiple sites' data throughout the session print('') Fish = raw_input("Paste excel data: ").upper() #lets us input our fish species, makes input uppercase Fi = Fish.split("\n") #creates a list based off our fish species Fi = Fish.split(",") Fi = list (OrderedDict.fromkeys(Fi)) #removes duplicates Fi.sort() #sorts the species alphabetically print '[%s]' % ', '.join(map(str, Fi)) #removes quotation marks and prints list