var1 = "54"
var4 = "32"
print(100 * str(int(var1) int(var4)))
Above, this is my code. can anyone tell me how to print the result 100 times in a new line? I tried many times using \n and with end keyword but I got errors and errors only.
CodePudding user response:
Use a for
loop:
var1 = '54'
var4 = '32'
for i in range(100):
print(int(var1) int(var4)) # prints 86
CodePudding user response:
I think you are trying.. for this
var1 = "54"
var4 = "32"
print(100 * (str(int(var1) int(var4)) str("\n"))) #This will print 86 100 times in new line
you can also use for loop for your desired output.
var1 = "54"
var4 = "32"
for i in range(100):
print(int(var1) int(var4)) #Same Output
You can apply while loop
also but when we know to iterate till specific value we should use for
.
There is no need of end="\n"
cause every time when for loop iterate print statement came into new line
If you wanted your data not in a new line but with a space or like tab than you will need to use end
ex:
print(int(var1) int(var4),end=" ")
This will print 86 with one space like. 86 86 86 ... 100times