我想循環輸入一段選定的時間「輸入你想要的成分如何:」如果用戶輸入5然後循環「成分」將運行5次他們輸入他們的成分。對不起,如果它看起來像一個基本的問題,但我很新。感謝您的任何答案:)。運行一個循環(x)時間
a=input("hello, welcome to the recipe calculator \nenter your recipe name, number of people you will serve and the list of ingredients \n1.retrive recipe \n2.make recipe \noption:")
if a=="2":
print("now enter the name of your recipe")
f=open('c:\\username_and_password.txt', 'w')
stuff = input("create name:")
nextstuff = (int(input("enter number of people:")))
nextstufff = (int(input("enter how many ingredients you want:")))
for (nextstufff) in range(0, 10): #I have put 0, 10 because the user probably wont put more than 10 ingredients. But there's probably a much better way?
print ("ingredient") + (nextstufff) #what am I doing wrong in this for loop
nextstuffff = (int(input("so how much of\n" + nextstufff + "would you like:")))
f.write(str(stuff + "\n") + str(nextstuff) + str(nextstufff))
f.close()
只是個頭,'nextstuff','nextstufff'和'nextstuffff'不是特別容易區分...... – StephenTG