Handling multiple variables in python
<p>Here's issue I am learning python newly i want to use loop for generating inputs from user which are then operated for some custom function (say Lcm or squaring them and returning ) so how to perform code 
Consider </p>

<pre><code>k,l=0,0

while l&gt;=10:
    n_k=input("Enter")
    k=k+1
    l=l+1
    #Do something within for loop
    #here problem begins 
    #lets say i am dividing each variable by c which is here in for loop 
    for c in range(somevalue,0,-1):
</code></pre>

<p>now how should i operate the variables clearly i have no intention writting n_0%c ,n_1%c etc 
<br><b>Any Help???</b></p>

<p>Instead of n_k being a single variable i think you want n to be a <a href="https://docs.python.org/2/tutorial/datastructures.html" rel="nofollow">list</a>. A list is just a bunch of variables stored together. For example the code:</p>

<pre><code>n = [1, 4, 2]


print(n[0]) #0th element of the list
print(n[1]) #1st element of the list
print(n[2]) #2nd element of the list
</code></pre>

<p>outputs </p>

<p>1<br>
4<br>
2<br></p>

<p>the line n = [1, 4, 2] is just defining the list. The elements of the list are accessed using the n[index] notation.</p>

<p>In python you can also add elements to a list at any time using the append statement. To illustrate let's define an empty list and add some elements to it.</p>

<pre><code>n = []
n.append(8)
</code></pre>

<p>Now if we try </p>

<pre><code>print(n[0])
</code></pre>

<p>the code will print 8.</p>

<p>So let's say we wanted to square a list of numbers we receive from user input, we would write</p>

<pre><code>n = []
k = 0

num_inputs = 10

while k &lt; num_inputs:
    n.append(input("Enter:"))
    k = k + 1

k = 0
while k &lt; num_inputs:
    print(n[k] * n[k])
    k = k + 1
</code></pre>

<p>Hope it helps.</p>

python python-2.7 loops variables for-loop