I am learning variable nested loops and this is the code in Python 2.
numLines = int(raw_input ('How many lines of stars do you want? '))
numStars = int(raw_input ('How many stars per line? '))
for line in range(0, numLines):
for star in range(0, numStars):
print '*',
print
This is the desired output (in Python 2):
How many lines of stars do you want? 3
How many stars per line? 3
* * *
* * *
* * *
But I am having a hard time getting Python 3 to achieve the same effect.
Here is my best attempt with getting the same output using Python 3:
numLines = int(input('How many lines of stars do you want? '))
numStars = int(input('How many stars per line? '))
for line in range(0, numLines):
for star in range(0, numStars):
print('*', end=" ")
print
Please advise.
Thank you very much.
Aucun commentaire:
Enregistrer un commentaire