counter=0
initials=0
name1=raw_input("Please enter your first name!")
name2=raw_input("Please enter your middle name!")
name3=raw_input("Please enter your last name!")
option=str(raw_input("a)Print the length of my name\nb)Print\nc)Exit\nChoose one of the options."))
while option != "c" or option != "C":
if (option=="a" or option=="A"):
print "Your first name has " + str(len(name1)) + " letters."
print "Your second name has " + str(len(name2)) + " letters."
print "Your last name has " + str(len(name3)) + " letters."
elif (option=="b" or option=="B"):
print name1[0] + "." + name2[0] + "." + name3[0]
elif (option=="c" or option=="C"):
break
這是我的代碼。由於某種原因,它會一直進入無限循環。一旦用戶選擇他們的選項,我該如何停止它?我只需要在那裏輸入用戶選擇一次的選項。Python編程無意循環
您的代碼的縮進似乎關閉。請檢查。 – usr2564301