【发布时间】:2013-11-19 02:45:45
【问题描述】:
希望你一切都好。
尝试创建一个充当字典的 Python 程序,但现在在创建 elif 语句时遇到了一些问题。我是我的空闲我不断收到迹象表明我的语法对于 elif 是错误的,但我并不是我做错了什么?我想这是一个缩进错误,但它到底是什么?
if choice == "0":
print "good bye"
elif choice == "1":
name = raw_input("Which philosopher do you want to get")
if name in philosopher:
country = philosopher [name]
print name, "comes from" , country
else:
print "No such term"
***elif choice == "2" :*** ***<<I am being told that I have syntax error in this elif element, what am I doing wrong)**
name = raw_input(" What name would you like to enter")
if name not in philosopher:
country = raw_input( "Which country do you want to put your philosopher in")
philosopher [name] = country
print name, "has now been added and he is from", country
else:
print "We already have that name"
【问题讨论】:
-
你不能在 else 之后有一个 elif。顺序为:if、elif、else
标签: python if-statement syntax indentation