0
python program to Reverse words in a given String in Python example str = "Capgemini" output should be reverse of that string li
Answer plz
3 Réponses
+ 3
string = "Hello"
string = string[::-1]
Output: olleH
--> string[start:end:steps]
Here we did not specify the 'start' and 'end' and these will be 0 and last element of the string by default, respectively.
-1 in steps means backward
Visit this link to learn more:
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_howto_reverse_string.asp
If you ever have questions about short codes like this, you can always use the search bar in code playground and google.
+ 3
str[::-1] , you should read about slicing in python.
Also please make sure to use search bar before asking a question, many times such questions have been answered already.
- 1
Bro this answer not showing any where in search bar