|  | 
 
 发表于 2017-8-24 21:27:10
|
显示全部楼层 
| 本帖最后由 这个胖子有点丑 于 2017-8-25 16:01 编辑 
 哈哈哈 我试着加了一些东西 这样更好玩哦!!!代码如下:
 
 import random
 x = random.randint(0,3)
 Name = ['小甲鱼','小瓜皮','小秃头','小油子']
 secret = Name[x]
 print('----------我爱鱼C工作室----------')
 temp = input('不妨猜一下我现在心里想的是那个名字:')
 for i in range(1,5):
 if i > 1:
 temp = input('再给你一次机会猜一下我现在心里想的是那个名字:')
 if i == 4 and temp != secret:
 print('你太笨了,答案是:%s' % secret)
 break
 if secret == Name[0]:
 
 if temp == secret:
 
 print('哇,你真的好爱小甲鱼啊!')
 print('哼,猜中了也没有奖励!')
 break
 
 else:
 if temp == Name[1]:
 print('你才是个瓜皮!!!')
 continue
 elif temp == Name[2]:
 print('你才是个秃头!!!')
 continue
 elif temp == Name[3]:
 print('你才是个油子!!!')
 continue
 
 elif secret == Name[1]:
 
 if temp == secret:
 
 print('哇,你真的好爱小瓜皮啊!')
 print('哼,猜中了也没有奖励!')
 break
 
 else:
 if temp == Name[0]:
 print('你才是个甲鱼!!!')
 continue
 elif temp == Name[2]:
 print('你才是个秃头!!!')
 continue
 elif temp == Name[3]:
 print('你才是个油子!!!')
 continue
 
 elif secret == Name[2]:
 
 if temp == secret:
 
 print('哇,你真的好爱小秃头啊!')
 print('哼,猜中了也没有奖励!')
 break
 
 else:
 if temp == Name[0]:
 print('你才是个甲鱼!!!')
 continue
 elif temp == Name[1]:
 print('你才是个瓜皮!!!')
 continue
 elif temp == Name[3]:
 print('你才是个油子!!!')
 continue
 
 elif secret == Name[3]:
 
 if temp == secret:
 
 print('哇,你真的好爱小油子啊!')
 print('哼,猜中了也没有奖励!')
 break
 
 else:
 if temp == Name[0]:
 print('你才是个甲鱼!!!')
 continue
 elif temp == Name[2]:
 print('你才是个秃头!!!')
 continue
 elif temp == Name[1]:
 print('你才是个甲鱼!!!')
 continue
 
 if temp not in Name:
 print('请不要乱猜!!!')
 continue
 print('游戏结束,不玩啦')
 
 大家可以试一试 还可以吧- -
 希望有大神来给我的代码提点意见,看能不能简化啊!!!
 | 
 |