Anton O. Obyedkov Anton O. Obyedkov - 5 months ago 30
Python Question

Asking for a short sentence, how many to appear, and print it out

I'm working on commands by telling them making a short sentence, asking how many to appear and prints it out that goes like this:

a=eval(input("Type something in short: "))
b=eval(input("How many?: "))
for b in a:
for a in range(b):

I need to ask people, Is there an error on a code on python?

Answer Source

I am guessing your objective is to print a b number of times.

For that, you don't need to even use a loop. Just do :


In : Type something in short : "abc"
In : How many?: "3"
Out : abcabcabc

Now, incase you wanted the string in new line, just add \n to the string.


In : Type something in short : "abc"
In : How many?: "3"
Out : abc

As for the error in your code, you have used an extra for loop and have a few mistakes. It should be :

for i in range(b):
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download