用户:
OOOOOOOOOOOOOOOOOOO查看:0 回复:0 评论:0 创建时间:2020-12-27T15:36:40
【作品展示】

【作品介绍】
双人游戏,希望大家喜欢
【作品源代码】
import random
import string
l = string.ascii_lowercase
n = random.randint(5,20)
s = ""
for i in range(n):
c = random.choice(l)
s = s + c
st = list(s)
print("回文字符串游戏")
round = 1
while True:
print("-----------------------------------------------------------------------------------------------------------")
print("第{}回合".format(round))
print("现在的字符串是:{}".format(st))
y = input(" >>请选择你要拿走的字符")
if y in st:
id = st.index(y)
st.pop(id)
print(" >>你选择拿走字符的是:{}".format(y))
print(" 你抽取后:{} ".format(st))
else:
print(" 你选择拿走的字符不存在 ")
o = 0
for c in st:
n = st.count(c)
if n % 2 == 1:
o = o + 1
if o <= 1:
print(" >>你赢了")
break
print("现在的字符串是:{}".format(st))
y = input(" >>请选择你要拿走的字符")
if y in st:
id = st.index(y)
st.pop(id)
print(" >>你选择拿走字符的是:{}".format(y))
print(" 你抽取后:{} ".format(st))
else:
print(" 你选择拿走的字符不存在 ")
o = 0
for c in st:
n = st.count(c)
if n % 2 == 1:
o = o + 1
if o <= 1:
print(" >>你赢了")
break
round = round + 1
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn