我是python新手,我只是尝试使用if语句进行简单的练习,但我希望我的语句能够循环,我拥有的是
species = "cat"
if species == "cat":
print("yep, it's a cat")
species = "dog"
if species == "dog":
print("and that's a dog")
species = "horse"
if species == "horse":
print("look at that horse over there")
species = "cheetah"
if species == "cheetah":
print("WHERE DID THE CHEETAH COME FROM?")
(是的,这有点傻)有没有办法连续循环语句,有没有办法限制它循环的次数?如果有更好的方法做我想做的事情,如果是什么
我会将这些数据存储在字典中,然后您可以循环:
相关问题 更多 >
编程相关推荐