Python项目求助
哥哥们这个怎么写呀? def mixer(a , b):r = ''
if a in '红绿蓝' and b in '红绿蓝'and a != b:
if a + b == '红绿' or a + b == '绿红':
r = '黄'
elif a + b == '红蓝' or a + b == '蓝红':
r = '紫'
else:
r = '青'
return r
a , b = input('请输入两种颜色(中间用空格隔开) : ') . split()
if a in '红绿蓝' and b in '红绿蓝'and a != b:
print(mixer(a , b))
else:
print('请输入两种原色(红、绿、蓝)') jackz007 发表于 2020-12-29 12:46
谢谢你!
colorlist=['红','绿','蓝']
def coloradd(x):
if x=='红绿' or x=='绿红':
color='黄'
return color
elif x=='红蓝' or x=='蓝红':
color='紫'
return color
elif x=='蓝绿' or x=='绿蓝':
color='青'
return color
while True:
color1=input('请输入颜色1(红绿蓝),输入“99”退出:')
color2=input('请输入颜色2(红绿蓝),输入“99”退出:')
if color1=='99' or color2=='99':
break
if (color1 not in colorlist) or (color2 not in colorlist):
print('请输入标准颜色')
continue
if color1==color2!='99':
print('请勿输入相同颜色')
continue
mix=color1+color2
colormix=coloradd(mix)
print(mix,'混合得到',colormix)
print('已退出!')
页:
[1]