yesstr=['yes','y']
nostr=['no','n']
abstainedstr=['abstained','a']
count=0
yescount=0
stra=stra.replace(',',' ')
for i in stra.split():
lowerstr=i.lower()
if lowerstr in yesstr:
yescount+=1
count+=1
elif lowerstr in nostr:
count+=1
if yescount==count:
return 'proposal passes unanimously'
if yescount*1.0/count>=2.0/3.0:
return 'proposal passes with super majority'
if yescount*1.0/count>=0.5:
return 'proposal passes with simple majority'
return 'proposal fails'
if __name__=='__main__':
stra=raw_input('Enter the yes,no,abstained votes one by one and the press enter:\n')
print vote(stra)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)