Reverse a string in Python

0 votes
How to reverse a string in Python?
Jun 21, 2019 in Python by Wajiha
• 1,950 points
240 views

1 answer to this question.

0 votes

You should try to use the following code which is an extended syntax of slice which works by using [begin:end:step] by leaving the begin and end off along with clarifying a -1 step which will reverse the string. 

>>> 'hello world'[::-1] 
'dlrow olleh'

answered Feb 8 by Rahul
• 8,980 points

Related Questions In Python

0 votes
1 answer

Reverse a string in Python

How about: >>> 'hello world'[::-1] 'dlrow olleh' This is ...READ MORE

answered Aug 1, 2018 in Python by Priyaj
• 58,080 points
229 views
0 votes
1 answer

Reverse a string in Python

>>> 'hello world'[::-1] 'dlrow olleh' This is extended slice syntax. Syntax is ...READ MORE

answered Nov 16, 2018 in Python by findingbugs
• 3,260 points
195 views
0 votes
1 answer

How to reverse a string in Python using slicing operator?

Hi@akhtar, Strings can be reversed using slicing. To ...READ MORE

answered Aug 17, 2020 in Python by MD
• 95,360 points
2,094 views
0 votes
1 answer

Reverse a string in Python

To reverse a string in Python we ...READ MORE

answered Feb 15 in Python by Dev
• 6,000 points
15 views
0 votes
1 answer

Reverse a string in Python

>>> 'hello world'[::-1] 'dlrow olleh' This is extended slice syntax. It ...READ MORE

answered Feb 15 in Python by CoolCoder
• 4,360 points
59 views
0 votes
1 answer

Concatenate 2 strings in R

You can use the paste() command: You can ...READ MORE

answered Apr 14, 2018 in Data Analytics by Sahiti
• 6,380 points
668 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
9,304 views
0 votes
1 answer

Join multiple strings in R

Joining strings in R is quite an ...READ MORE

answered Jul 19, 2018 in Data Analytics by DataKing99
• 8,240 points
903 views
0 votes
2 answers

What's the difference between %s and %d in Python string formatting?

The reason is that they are using ...READ MORE

answered Feb 8 in Python by Rahul
• 8,980 points
31 views
0 votes
1 answer

TypeError: a bytes-like object is required, not 'str' when writing to a file in Python3

After what I observed, you would have ...READ MORE

answered Feb 11 in Python by Rahul
• 8,980 points
161 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP