I want to show numbers in a row. Python 3.6

0

I want to show the data output as a queue, for how many times the user wants it.

def ex1():
    valo = int (input("Insira o numero"))
    for t in range (1,valo+1):
        print((int(valo))*1)
print (ex1())

Ex: times = 4

Saida:
4
44
444
4444
    
asked by anonymous 27.03.2018 / 16:38

2 answers

0

In python, when a% is made with%% with_% 1 number this indicates how many times it will repeat the string , its function might look like this:

def ex1(): 
    valor = input("Insira o numero: ") 
    repeticoes = int(input("Insira quantas repeticoes deseja: "))
    for item in range(repeticoes + 1):
        print(valor * int(item))

Output example:

  

Enter the number: 4

     

Enter how many repeats you want: 4

     

4   44   444   4444

    
27.03.2018 / 16:51
0

Serves for numbers, characters, and also strings:

>>> '4'*2
'44'
>>> '4'*10
'4444444444'
>>> 'a'*10
'aaaaaaaaaa'
>>> 'abc'*3
'abcabcabc'

In the case of your code, you do not need to convert it to an integer and you can use what was received by the input () function.

    
27.03.2018 / 16:44