+ 10
Can someone please help me to solve this question using Phyton?
35 Antworten
+ 10
x = input()
print(x[::-1])
This is the shortest method to solve the question
But you have aready solved this question, right?
+ 15
Check my codes they all are in python
+ 4
Ok then copy your code and paste here
+ 4
Can you explain why?
+ 4
Ok
Thanks a lot
I really appreciate your help
Thanks guys
+ 4
Ok👌
Thank you
Thank you
Thank you
+ 4
You can see the explaination + solution here
https://code.sololearn.com/W5Dyu7fP15N8/?ref=app
BTW you misspelled Python
+ 3
A string can also be said as a list of letters...
To get some part of a list:-
List[start(default=0) : end(default=len(List)) : step(default=1)]
So with this we are decreasing our steps by putting -1....
For understanding we can also type:
print(x[0:len(x):-1])
+ 3
Try this code(this code is available for a sentence too andi not only words)
sentence_in_english = input()
sentence_inverse = []
for word in sentence_in_english.split():
word_inverse = word[::-1]
sentence_inverse += word_inverse
print("".join(sentence_inverse))
+ 3
string = input()
#we use input() for asking input from the user and assigning to an argument called string.
print(string[::-1])
#we can slice the string using [ ] called slicing operator. If you have learned about list and their indices then you will be clear that negative index is used for reversing. The same list method can be established for string also.
+ 3
Phyton?
+ 3
Check this
https://www.sololearn.com/coach/51?ref=app
+ 3
(•‿•)
+ 2
Please show up your attempt first and then if any errors found we will help you out...
+ 2
Please post in over here or send a link of your code
+ 2
Hadif Syahputra The problem is that you didn't take the input at run time
+ 2
Ok
+ 2
It is so easy to reverse a word but if we need to reverse all words in a sentence, the code would be like this:
def rev(string):
b=list(string)
b.reverse()
sep=''
l=sep.join(b)
return l
ourlang=input('Enter the sentence to be converted:')
k=list(ourlang.split(' '))
for i in k:
c= rev(i)
print(c,end=' ')
+ 1
Ok