我目前正在为一所学校的项目工作,但我遇到了一些麻烦。
def index_district():
district = input("Please enter district: ")
candidates = []
var1 = 0
while var1:
var1 += 1
candidates_names = input('Enter name of candidate. Hit enter again to end ')
if candidates_names == '':
break
candidates.append(candidates_names)
votes = []
var2 = 0
while var2:
var2 += 1
candidates_votes = input('Enter number of votes. Hit enter again to end ')
if candidates_votes == '':
break
votes.append(candidates_votes)
parties = []
var3 = 0
while var3:
var3 += 1
candidates_parties = input('Enter party. Hit enter again to end ')
if candidates_parties == '':
break
parties.append(candidates_parties)
canidate_parties = dict(zip(parties, candidates))
party_votes = dict(zip(parties, votes))
print(canidate_parties)
print(party_votes)
print(district)
#d1= canidate_parties, party_votes
index_district()
它获取了分区,但随后从分区=输入一直跳到打印行。
这是我的输出
Please enter district: dd
{}
{}
dd
我尝试了一个较小的版本,只制作了两个列表,它运行得很好。所以我有点难过我在这里做错了什么。任何帮助,将不胜感激。谢谢你的时间。