Reverse a string in Python

0 votes
How to reverse a string in Python?
Jun 21, 2019 in Python by Wajiha
• 1,950 points
492 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, 2022 by Rahul
• 9,670 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,090 points
574 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
490 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,440 points
3,322 views
0 votes
1 answer

Reverse a string in Python

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

answered Feb 15, 2022 in Python by Dev
• 6,000 points
315 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, 2022 in Python by CoolCoder
• 4,400 points
590 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,370 points
1,099 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
11,771 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
1,323 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, 2022 in Python by Rahul
• 9,670 points
20,258 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, 2022 in Python by Rahul
• 9,670 points
1,584 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP