0
[SOLVED] How can i make a variable changes its name according to the iteration of the for loop??
Python Loops Variables
5 Answers
+ 1
Variable's names usually don't change at all.
Can you tell us more about what you're trying to do? Maybe we know another solution to what you want to do.
Also, why is this about Java, JS and Python?
+ 2
Is this for Python, Javascript, or Java? Multiple tags are useless and need to be removed for clarification.
+ 1
How about using a dictionary?
There you can store something (also a list) under a key.
nums = [7, -5, 3]
stuff = {}
for n in nums:
stuff[n] = [float(n), abs(n), str(n)]
print(stuff[-5])
Try this.
You basically only need to change what you store under each key (your calculation).
0
In python
I have a list of numbers
Using for loop am ganna create lists which contains divisors of each num.
At the end i want to combine them then get the maximum as the gcd of those nums
What it needs is to change the name of the list according to the num.
0
Yh it seems right!