我正在做一种测验,想知道如何将结果与文本文件进行比较。在根据提示输入回答问题后,该函数将返回一个四位数代码。我希望将该四位数代码与我写出的文本文件中的“truecode”进行比较,并提供如下附加信息:
villagername,personality,birthday,zodiac,truecode,species
Ankha,snooty,September 22nd,Virgo,A420,Cat
Bangle,peppy,August 27th,Virgo,A330,Tiger
Bianca,peppy,December 13th,Sagittarius,A320,Tiger
Bob,lazy,January 1st,Capricorn,A210,Cat
Bud,jock,August 8th,Leo,A310,Lion
我希望打印出这些其他信息。
print("Your villager is " + villagername)
print("They are a " + personality + " type villagers and of the " + species + " species.")
print("Their birthday is " + birthday + " and they are a " + zodiac)
print("I hope you enjoyed this quiz!")
我不知道如何提取这些信息并将其与我所拥有的进行比较。我应该使用列表还是字典?试图用谷歌搜索我的问题并想知道我是否完全错误地解决了这个问题,我感到很沮丧。
我如何将四位数代码(将从另一个函数返回)与“真实代码”进行比较,并像上面那样吐出所有内容?
拉莫斯之舞
繁星点点滴滴
慕运维8079593
相关分类