sports=['CRICKET','BADMINTON','TENNIS']
bollywood=['WAQT','GULAAL','MAQBOOL']
food=['RAVA DOSA','IDLI SAMBHAR','CENTURY EGG']
print """Choose Your Field
1. SPORTS
2. BOLLYWOOD
3. FOOD"""
field=raw_input('\n Enter Field :')
现在用户将进入该字段,然后应该有一些函数将从该给定字段(列表)返回随机值。
答案 0 :(得分:1)
import random
myList = []
myList.append(['CRICKET','BADMINTON','TENNIS'])
myList.append(['WAQT','GULAAL','MAQBOOL'])
myList.append(['RAVA DOSA','IDLI SAMBHAR','CENTURY EGG'])
print """Choose Your Field
1. SPORTS
2. BOLLYWOOD
3. FOOD"""
field=raw_input('\n Enter Field :')
print random.choice(myList[int(field) - 1])
您还应该对输入进行错误检查,以确保它确实是一个有效的条目