while True:
import csv #Creates a CSV file
name = input("Hello what is your name?")
print("Hello",name,"!")
opinion = input ("How do you feel about the Icentre A. Good B. Amazing C. I don't like it Please type your answer here -->")
if opinion == 'Good'or opinion == 'good' or opinion == 'A' or opinion == 'a':
print("Thanks!")
improvements = input("Anything we can improve?")
print("Thanks for your feedback!")
reason = ""
elif opinion == 'Amazing' or opinion == 'amazing'or opinion == 'B' or opinion == 'b':
print("Thats awesome!")
improvements = input("Anything we can improve?")
print("Thanks for your feedback!")
reason = ""
elif opinion == 'I dont like it' or opinion == 'i dont like it'or opinion == 'C' or opinion == 'c':
reason = input("Please tell us why -->")
print("Thank you for your feedback.")
improvements = ""
results = [
[name, opinion, improvements, reason]
]
#w = write, a = append
myfile = open("OpenEveningResults.csv", "a", newline="")
mywriter = csv.writer(myfile)
mywriter.writerows(results)
myfile.close()
if name == "stop":
break
这是说"打破'外循环"。这是一个错误,但我无法看到我在代码中出错的地方。不确定我是否缩进错误或分开,以及不应该分开的代码。
答案 0 :(得分:0)
while True:
其余的代码都在这里,缩进。
答案 1 :(得分:0)
您需要为while循环体使用缩进,如下所示:
while True:
import csv #Creates a CSV file
name = input("Hello what is your name?")
print("Hello",name,"!")
opinion = input ("How do you feel about the Icentre A. Good B. Amazing C. I don't like it Please type your answer here -->")
if opinion == 'Good'or opinion == 'good' or opinion == 'A' or opinion == 'a':
print("Thanks!")
improvements = input("Anything we can improve?")
print("Thanks for your feedback!")
reason = ""
elif opinion == 'Amazing' or opinion == 'amazing'or opinion == 'B' or opinion == 'b':
print("Thats awesome!")
improvements = input("Anything we can improve?")
print("Thanks for your feedback!")
reason = ""
elif opinion == 'I dont like it' or opinion == 'i dont like it'or opinion == 'C' or opinion == 'c':
reason = input("Please tell us why -->")
print("Thank you for your feedback.")
improvements = ""
results = [
[name, opinion, improvements, reason]
]
#w = write, a = append
myfile = open("OpenEveningResults.csv", "a", newline="")
mywriter = csv.writer(myfile)
mywriter.writerows(results)
myfile.close()
if name == "stop":
break