+ 4
Please anyone help me with this code.
I want space between each number in output n=int(input()) list1=input() length=len(list1) if length == n : print(list1[::-1]) >>>Input (stdin) 5 12345 Your Output (stdout) 54321>>>
18 Respostas
+ 4
print(*list[::-1])
Using this you will get your desired output..
just make this change(as mentioned above)in your code
HOPE IT HELPS!!!âșïž
+ 3
Ramya Thiurmalisamy
* symbol is use to print the list elements in a single line with space and in strings as well
+ 2
Ok, then do one thing, create an empty string outside loop(for eg. x) and then do this -
for i in list1[::-1]:
x += i + " "
print(x)
+ 2
you can use this code
For i in list1[::-1]:
X+=I+" "
Print (x)
+ 2
n=int(input())
list1=input()
length=len(list1)
If length==n
For i in list1:
Print(i," ")
+ 1
Simply take every input as string eventhough it's a number... Or else use the logic of reverse of a number...(not exact logic, modify the code and use)
+ 1
What I am saying is -
After the if statement,
for i in list1[::-1]:
print(i + " ")
+ 1
This is it.
list=[12345]
rev=list[::-1]
print (rsd, sep=' ')
To print in new lines, a loop is best.
0
Add a for loop in it printing each element + " "(space)..
0
RAJESH SAHU yeah!!! It's work.but can you explain how it is?
0
Varun Vaswani can you explain how I can use for loop here?I can't able to understand what you say!!
0
Varun Vaswani but it givese a output in newlines not in a same line.đđđ€
0
@ Varun Vaswani ok I will check it out.Tq
0
Welcome
0
@yeah!!!it's working đđđ€đ€đđ€©đâšđ«
0
Varun Vaswani it'll also print space at the end which we won't need...!!