我的代码(如下所示)继续返回编程错误,例如,如果我输入0,它仍然表示答案无效,我知道有一些我忽略的东西,任何帮助将不胜感激! (对不起,如果它真的很简单,我只是没有注意到,这是我第一次编码)
with open ("Lineup.csv", "rt") as fileopen:
file = csv.reader(fileopen, delimiter=',')
array = []
score = 0
for row in file:
array.append(row)
for i in array:
like = ""
likeness = ""
print(i)
like = print(input("If 1 is yes and 0 is no, do you like/know this band?"))
if like == "0":
score + 0
like = ""
if like == 1:
print(i)
like = 0
likeness = print(int(input("If 1 is worst and 3 is best, how much do you like them?")))
if likeness == 1:
score + 1
likeness = 0
if likeness == 2:
score + 2
likeness = 0
if likeness == 3:
score + 3
likeness = 0
else:
print(i)
likeness = print(int(input("Answer was not valid, please choose a number from 1-3, how much do you like this band?")))
else:
print(i)
like = print(input("Answer was not valid, please choose 0 or 1, do you like this band?"))
file.close
答案 0 :(得分:0)
with open ("Lineup.csv", "rt") as fileopen:
file = csv.reader(fileopen, delimiter=',')
array = []
score = 0
for row in file:
array.append(row)
for i in array:
like = ""
likeness = ""
print(i)
like =input("If 1 is yes and 0 is no, do you like/know this band?")
print like
if like == "0":
score + 0
like = ""
if like == 1:
print(i)
like = 0
likeness = int(input("If 1 is worst and 3 is best, how much do you like them?"))
print likeness
if likeness == 1:
score + 1
likeness = 0
if likeness == 2:
score + 2
likeness = 0
if likeness == 3:
score + 3
likeness = 0
else:
print(i)
likeness = print(int(input("Answer was not valid, please choose a number from 1-3, how much do you like this band?")))
else:
print(i)
打印值时,不会将其分配给变量。只需修复它就可以了。