如何改成def自定义函数
import random
print('''
zhou1118的猜拳游戏
===========================
出拳说明
0:石头
2:剪刀
5:布
''')
score_h=3
score_r=3
while score_h>0 and score_r>0:
h=input('请出拳:')
while not h in ['0','2','5']:
h=input('您的输入错误,请重新出拳:')
r=random.choice(['0','2','5'])
if r=='0':
print('我出的是石头')
elif r=='2':
print('我出的是剪刀')
else:
print('我出的是布')
if h=='0':
print('您出的是石头')
elif h=='2':
print('您出的是剪刀')
else:
print('您出的是布')
if h==r:
print('平局')
elif h=='0'and r=='2'or h=='2'and r=='5' or h=='5' and r=='0':
if r=='0':
score_r-=1
print('您赢了'.format(score_r,score_h))
else:
score_h-=1
print('您输了'.format(score_r,score_h))