我有一個任務要求用戶有多少個方向他們有一個Finch機器人在Python中。 在我有多少方向之後,我需要詢問並保存其中的每一個。 我無法弄清楚的是如何切換我正在使用的變量並仍然存儲用戶的答案。如何更改正在使用的變量?
count = 1
nod = int(input("How many directions do you have?: ")) #nod = number of directions
for int in range(0, nod):
d1 = str(input("Direction " + str(count) + ": "))
#I want to switch out d1 with d2,d3, etc. for as many directions as the user has
count += 1
你使用Python 3嗎? –