(Aug-15-2017, 04:27 PM)nilamo Wrote: [ -> ]How do you know that a Ryanair is a 6?
Unless you put it somewhere in your program (or if it's standardized, use a library/service), how do you expect python to know that whatever a "Ryanair" is means whatever meaning you attach to "6"? To python, they're just unrelated strings/numbers.
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
(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.
(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
Ok, but those numbers are meaningless. Unless you create a dictionary that maps all of those things to whatever number they represent, that is.
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.
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.
(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!