write a program using python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

write a program using python

printing a given number for given number of times. example1: enter a number : 7 7777777 example2: enter a number : 4 4444

19th Feb 2020, 1:32 PM
nithish
nithish - avatar
20 Answers
+ 13
nithish , please follow rules of this forum. You can't ask people to do your work. You need to first try it yourself. Just to give you some algorithm : 1. input number. (as string) 2. in python you can multiply string by integer "a"*5 gives "aaaaa" so just convert input string to integer and multiply string by that integer. another approach can be using loop. all you need to know is how to convert string to int and how to print.
19th Feb 2020, 1:42 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 10
nithish , If you have just started python, have some patience. If we give you code you'll not be able to learn. Continue with course, use "try it yourself" button whenever it's there. You can do this 👍
19th Feb 2020, 1:46 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 6
nithish , Wow! You are advancing 😁🍻 You couldn't learn this if you didn't try. I'm glad for you. Happy learning.
19th Feb 2020, 2:21 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 4
nithish , line 3: print ([x] * x) this seems to work but format isn't exactly as you mentioned. You should counvert x to string using `str()` instead of [ ] line 9 to 12 : for(int i=0; i<=x ; i++) { print( x ) } well , this isn't python. You are using C like syntax. review the lesson about loops. and print() function adds a newline charecter at end of string. to avoid that newline use end = " " print( x , end = "" ) Well done, You tried to do this 💪
19th Feb 2020, 2:09 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
19th Feb 2020, 2:19 PM
nithish
nithish - avatar
+ 1
Did you try?
19th Feb 2020, 1:38 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
nithish Ok, at least show us the code you tried and we will try to help you. Now you have an algorithm from 🇮🇳Omkar🕉
19th Feb 2020, 1:46 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
nithish , Code coach requires you to do only what is mentioned in challenge, nothing more. Just a single unnecessary charecter can make all test cases fail. They never asked you to check if popsicles > siblings There can be only two possible outputs "give away" or "eat them yourself". The outer if(popsicles > siblings){ }else{ } is unnecessary. also please make new question instead of asking here. because it's not related to this question.
19th Feb 2020, 3:16 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
A=int(input ('enter a number:')) print(STR(A)*A)
21st Feb 2020, 7:22 AM
Ujjwal Pratap Singh
Ujjwal Pratap Singh - avatar
+ 1
Num = eval(input('Enter a number : ')) For i in range(num) Print('num'*num)
21st Feb 2020, 10:53 AM
Pranav
Pranav - avatar
0
Mihai Apostol I'm just started learning python few minutes ago and i tried but i didn't got. can you solve it for me🤗
19th Feb 2020, 1:42 PM
nithish
nithish - avatar
0
Last part is not in Python. Just remove it. You read an integer. To cast it into a string use str(x) not [x]
19th Feb 2020, 2:05 PM
Mihai Apostol
Mihai Apostol - avatar
0
Mihai Apostol 🇮🇳Omkar🕉 i don't know what's the problem in this code popsicles code coach https://code.sololearn.com/cPRiV4jZz9zm/?ref=app
19th Feb 2020, 3:05 PM
nithish
nithish - avatar
0
https://code.sololearn.com/cs0tg6DmTKpl/?ref=app
20th Feb 2020, 12:12 PM
Vikas Chaubey
Vikas Chaubey - avatar
0
You can use the for loop and also range..for X in range(what ever range) Print (int)
20th Feb 2020, 3:34 PM
Bolajoko Damilola
Bolajoko Damilola - avatar
20th Feb 2020, 9:20 PM
JAYANTHI SAI GOPAL
JAYANTHI SAI GOPAL - avatar
0
char = str(input()) print(char * int(char))
20th Feb 2020, 9:46 PM
Eduardo Cavalcante
Eduardo Cavalcante - avatar
0
number = int(input("enter the number: ")) print(str(number)*number)
21st Feb 2020, 2:41 AM
Matias Henriquez
Matias Henriquez - avatar
0
This is the code bro: A=int(input('enter :')) Print(str(A)*A)
21st Feb 2020, 5:26 AM
vaggu deekshith
vaggu deekshith - avatar