我这样做的目的是,如果用户输入“g”作为输入,它会将其转换为“绿色”…“r”=红色”…“c”=青色…以此类推
有没有办法用某种循环来代替呢?谢谢
for i in range(3):
findColours = input("Enter you're colours -Choose from [red, green, blue, orange, magenta, cyan]:")
if findColours == "r":
findColours = "red"
elif findColours =="g":
findColours = "green"
elif findColours =="b":
findColours = "blue"
elif findColours =="o":
findColours = "orange"
elif findColours =="m":
findColours = "magenta"
elif findColours =="c":
findColours = "cyan"
你可以用字典来做这个。想法如下:
希望这有帮助!你知道吗
相关问题 更多 >
编程相关推荐