从以下代码开始:
green = "formed after combining blue and yellow".
orange = "formed after combining red and yellow".
colour = str(input("enter a colour"))
if colour == "green":
print(f "The colour {colour}, {green} ")
if colour == "orange": print(f "The colour {colour}, {green} ")
print(f "The colour {colour}, {orange} ")
我如何制作它,以便在如何形成颜色的答案被打印后,用户再次被要求变量“颜色”或另一个输入,再次询问他是否想咨询如何形成另一种颜色。
当用户第一次想知道绿色是如何形成的,然后想知道橙色是如何形成的,或者棕色等等,你可以一直向他展示输入,直到他回答“否”或“结束”为止。
最后,应该有这样的信息。如果您不想知道更多的颜色,按这样和这样,程序结束。
我知道你需要一段时间,但我在youtube上找不到令人满意的解释。
发布于 2022-01-11 16:19:03
green = "formed after combining blue and yellow"
orange = "formed after combining red and yellow"
while True:
color = input("enter a color: ")
if color == "green":
print(f"The color {color}, {green}")
elif color == "orange":
print(f"The color {color}, {orange}")
choice = input("do you want to consult how to form another color: ")
if choice == "yes":
continue
elif choice == "no":
break
https://stackoverflow.com/questions/70669726
复制相似问题