Reputation: 11
I am currently a beginner is pythonand I want to know what's a simpler way doing this method below?
for i in range (20100,20130):
print ("s0", i, "@gmail.com", sep='')
for i in range (20200,20230):
print ("s0", i, "@gmail.com", sep='')
for i in range (20300,20330):
print ("s0", i, "@gmail.com", sep='')
for i in range (20400,20430):
print ("s0", i, "@gmail.com", sep='')
for i in range (20500,20530):
print ("s0", i, "@gmail.com", sep='')
for i in range (20600,20630):
print ("s0", i, "@gmail.com", sep='')
Upvotes: 0
Views: 38
Reputation: 1952
One of the strengths of using Python is that you can nearly always put any loop/structure/if statement in another loop/structure/if statement.
Code:
for j in range(20100,20601,100):
for i in range (j,j+30):
print ("s0", i, "@gmail.com", sep='')
Now, we loop through 2 variables!
Upvotes: 2