python是哪种动物

编程入门 行业动态 更新时间:2024-10-11 23:16:19

python是<a href=https://www.elefans.com/category/jswz/34/1769624.html style=哪种动物"/>

python是哪种动物

我想这就是你要找的代码。测试过了。工作完美。试试这个。在import random

animal = {'lion': ['mane', 'teeth', 'pride', 'Africa', 'predator'],

'tiger': ['stripes', 'fur', 'endangered', 'cat', 'claws'],

'bear': ['hibernates', 'North America', 'Brown', 'Fur', 'Strong'],

'owl': ['hoot', 'nocturnal', 'flies', 'big eyes', 'eats mice'],

'frog': ['pond', 'green', 'tongue', 'amphibian', 'eats flies'],

'toucan': ['rainbow', 'long beak', 'South America', 'tropical', 'wings'],

'monkey': ['eats bananas', 'trees', 'tail', 'swing', 'primate'],

'shark': ['ocean', 'dangeous', 'cartilege', 'sharp teeth', 'fins'],

'zebra': ['stripes', 'black and white', 'africa', 'safari', 'hoofs'],

'wolverine': ['vicious', 'skunk bear', 'brown', 'small', 'fast']}

randomanimal = random.choice(dict(enumerate(animal)))

guess = ""

attributes = animal[randomanimal]

print ("Let's play a game!")

print ("Guess the animal I'm thinking of.")

while guess != randomanimal:

if guess in attributes:

print ("yes")

elif guess in animal.keys():

print ("Try Again")

elif guess != "":

print ("no")

guess = raw_input('What animal am I thinking of?')

print ("You Win")

希望这有帮助。在

更多推荐

python是哪种动物

本文发布于:2024-03-07 22:55:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1719133.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:哪种   动物   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!