+ 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
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.
+ 6
nithish ,
Wow! You are advancing ๐๐ป
You couldn't learn this if you didn't try.
I'm glad for you. Happy learning.
+ 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 ๐ช
+ 4
+ 1
Did you try?
+ 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๐
+ 1
+ 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.
+ 1
A=int(input ('enter a number:'))
print(STR(A)*A)
+ 1
Num = eval(input('Enter a number : '))
For i in range(num)
Print('num'*num)
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๐ค
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]
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
0
https://code.sololearn.com/cs0tg6DmTKpl/?ref=app
0
You can use the for loop and also range..for X in range(what ever range)
Print (int)
0
char = str(input())
print(char * int(char))
0
number = int(input("enter the number: "))
print(str(number)*number)
0
This is the code bro:
A=int(input('enter :'))
Print(str(A)*A)