我在这方面做了很多研究,但我不知道我做错了什么。请帮忙!!!你知道吗
课程目标:
不断地问一个问题来为用户选择一个选项,直到用户在提供的列表中选择一个为止。
问题:我就是无法使用not
关键字。你知道吗
代码语法:
items = {'1': '2', '3': '4', '5': '6'}
choice = input("Select your item: ")
print(choice)
for choice not in items:
if choice in items:
the_choice = items[choice]
print("You chose",the_choice)
break
else:
print("Uh oh, I don't know about that item")
来自eclipse的错误:
for not choice in items:
^
SyntaxError: invalid syntax
只需忽略代码中的not关键字
试试这个:
相关问题 更多 >
编程相关推荐