Python Forum
Print 'X' a number of times - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Print 'X' a number of times (/thread-23817.html)



Print 'X' a number of times - Than999 - Jan-18-2020

Hi What is wrong with my code? I'm trying to print the a number of 'X' strings based on my input value (integer). However, when I try to run it in my Python IDE, there is no output for some reason, nor do I get any error message. Any help or suggestion would be greatly appreciated.

numXs = int(input('How many times should I print the letter X? '))

toPrint = ''

while numXs >= 0:

    toPrint = numXs * 'X'

print(toPrint)



RE: Print 'X' a number of times - Larz60+ - Jan-18-2020

numXs = int(input('How many times should I print the letter X? '))
print('X'*numXs)
result:
Output:
XXXXXXXXXX