I need help - 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: I need help (/thread-4422.html) Pages:
1
2
|
RE: I need help - 777CAIN - Aug-15-2017 (Aug-15-2017, 04:27 PM)nilamo Wrote: How do you know that a Ryanair is a 6? No I want to make a program so if a user types in Ryanair it comes back with the number 6 and then if someone types in AAL it comes back with 11 ect ect ect for every airline RE: I need help - nilamo - Aug-15-2017 (Aug-15-2017, 04:31 PM)777CAIN Wrote: No I want to make a program so if a user types in Ryanair it comes back with the number 6 and then if someone types in AAL it comes back with 11 ect ect ect for every airline Ok, but those numbers are meaningless. Unless you create a dictionary that maps all of those things to whatever number they represent, that is. RE: I need help - 777CAIN - Aug-15-2017 (Aug-15-2017, 04:42 PM)nilamo Wrote:(Aug-15-2017, 04:31 PM)777CAIN Wrote: No I want to make a program so if a user types in Ryanair it comes back with the number 6 and then if someone types in AAL it comes back with 11 ect ect ect for every airline You lost me... i just want to make a program (im new to coding) where someone puts a word and it comes back as a number thats all. RE: I need help - nilamo - Aug-15-2017 items = { "Ryanair": 6, "AAL": 11 } thing = input("Check which? ") if thing in items: print(items[thing]) else: print("Invalid input")How's that? It's just a map of keys to the number they associate to, and prints it when someone types in the key. RE: I need help - 777CAIN - Aug-15-2017 (Aug-15-2017, 04:49 PM)nilamo Wrote:items = { "Ryanair": 6, "AAL": 11 } thing = input("Check which? ") if thing in items: print(items[thing]) else: print("Invalid input")How's that? It's just a map of keys to the number they associate to, and prints it when someone types in the key. Thank you so much thats how i wanted it to work! |