Python Forum
Changing a variable's name on each iteration of a loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing a variable's name on each iteration of a loop
#1
Is it possible in python to change the name of a variable on each iteration of a loop? For example:
for i in range(10):
    variableNameToChange+i="iterationNumber=="+str(i)
I know this won't work, and you can't assign to an operator, but how would you change / add to the name of a variable on each iteration of a loop, if it's possible?
Reply


Messages In This Thread
Changing a variable's name on each iteration of a loop - by rix - Jan-03-2020, 01:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 375 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,528 Nov-07-2023, 09:49 AM
Last Post: buran
  Inconsistent loop iteration behavior JonWayn 2 957 Dec-10-2022, 06:49 AM
Last Post: JonWayn
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,532 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  loop (create variable where name is dependent on another variable) brianhclo 1 1,104 Aug-05-2022, 07:46 AM
Last Post: bowlofred
  Multiple Loop Statements in a Variable Dexty 1 1,176 May-23-2022, 08:53 AM
Last Post: bowlofred
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,131 Mar-16-2022, 08:54 PM
Last Post: cubangt
  Keeping a value the same despite changing the variable it was equated to TheTypicalDoge 2 1,433 Mar-13-2022, 10:50 PM
Last Post: Yoriz
  How to save specific variable in for loop in to the database? ilknurg 1 1,113 Mar-09-2022, 10:32 PM
Last Post: cubangt
  How to add for loop values in variable paulo79 1 1,411 Mar-09-2022, 07:20 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020