I'm making a very simple graphical program and am quite new.
nums = ["second", "third", "fourth"] for colours in range(3): numString = nums[colours] inputWindow.getMouse() colour1 = inputBox.getText() inputBox.setText("") instruction.setText("Please enter the {0} colour: ".format(numString)) Where I put 'colour1', I want it to cycle through colour1, colour2, colour3 and colour4 on each iteration (without using a long if statement). Dictionary cannot be used for this particular program.
At the end, the function returns all of these colours inputted from the user. I tried using a list but realised you can't use them for variable names.
Thanks for help.
Edit: Seeing as there's a lot of confusion (which I'm sorry for), I'll try and explain better: My code up there is kind of strange and comes from nowhere. I'll simplify it:
def getInputs(): for colours in range(3): colour1 = userInput() return colour1, colour2, colour3, colour4 This is basically the gist. I wanna know if there's a way to cycle through the different variables where 'colour1 = userinput()' is (without using dictionary).