帮我优化一下代码 x = int("输入几朵玫瑰花:") if x ==1: print ("1朵:一心一意") elif x==2: print("2朵:二人同心") elif x==3: print("3朵:三羊开泰") else: print("不知道了,可以输入1,2,3朵") 再优化一下 无法运行,优化一下
你需要将代码放入一个函数中,并添加一个 input() 函数来获取用户输入。
def meaning_of_roses(): x = int(input("输入几朵玫瑰花:")) if x == 1: print("1朵:一心一意") elif x == 2: print("2朵:二人同心") elif x == 3: print("3朵:三羊开泰") else: print("不知道了,可以输入1,2,3朵")
meaning_of_roses()
原文地址: https://www.cveoy.top/t/topic/g80 著作权归作者所有。请勿转载和采集!