TypeError: list indices must be integers, not tuple

james8booker at hotmail.com james8booker at hotmail.com
Mon Feb 9 18:52:52 EST 2015


import random
RandomNum = random.randint(0,7)
restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or Indian?")
if restraunt == ("Pizza"):
    fav = ("1")

elif restraunt == ("Chinease"):
    fav = ("2")  

elif restraunt == ("Indian"):
    fav = ("3")
    
else:
    print("Try using a capital letter, eg; 'Chinease'")
    
Menu = [["Barbeque pizza","Peparoni","Hawain"],["Curry","Noodles","Rice"],["Tika Masala","Special Rice","Onion Bargees"]]

print Menu[fav,RandomNum]
                   ^
TypeError: list indices must be integers, not tuple

How do I set a variable to a random number then use it as a list indece, (I'm only a student in his first 6 months of using python) 



More information about the Python-list mailing list