0
Please help me I had typed a list And list as content but I want to print Piyush prajapati Not ['piyish', 'prajapati']
content = [ "piyish" , "prajapati" ] x = 0 while x < 3: print(content) x = x + 1 break Output ['piyish', 'prajapati'] [Program finished]
10 Respuestas
+ 6
#In place of print(content), write This
content = [ "piyush" , "prajapati" ]
x = 0
while x < 3:
print(*content)
x = x + 1
break
#It's printing list because you have used list.
However, try the above code and one more thing you have written "piyish" there if you want "piyush"
Change it.
And if you want it 3 times as Ipang said remove the break statement in your code as it breaks the loop from repeating the code
+ 6
What's the problem in it or what do you want in it..
Also tell us your problem with code
+ 6
This is a comprehension that can do the task:
[print(i,end=' ') for i in content]
+ 5
The loop runs only once instead of three times (as planned), that is because you put a `break` statement in the loop body. Just remove the `break` statement and it will run three times.
(Edit)
I misunderstood the question, because the desired output was not specified early on.
+ 2
print (" ". join(content))
+ 1
Thanks bro
+ 1
PIYUSH PRAJAPATI
nope
standard repertoire.
one should know it...
... not pure beginner, but after.
0
Please help me I had typed a list And list as content but I want to print
Piyush prajapati
Not
['piyish', 'prajapati']
0
It kinda tricky??
Oma falk
0
Use the print () tag to get the resulting output