+ 1

How to invert a string in python

Ex: Air Ria

17th Dec 2019, 10:10 AM
Arydev
Arydev - avatar
7 Answers
+ 1
To replace a string, use the following code: 1) string="hi world" 2) new_string=string.replace ("hi","hello") 3) print (new_string) ***output***: hello world
18th Dec 2019, 3:00 PM
๐Ÿ‡ฒโ€‹๐Ÿ‡ดโ€‹๐Ÿ‡ญโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ฒโ€‹๐Ÿ‡ฒโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ฉโ€‹ ๐Ÿ‡ฏโ€‹๐Ÿ‡ฎโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ณโ€‹
๐Ÿ‡ฒโ€‹๐Ÿ‡ดโ€‹๐Ÿ‡ญโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ฒโ€‹๐Ÿ‡ฒโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ฉโ€‹ ๐Ÿ‡ฏโ€‹๐Ÿ‡ฎโ€‹๐Ÿ‡ฑโ€‹๐Ÿ‡ฆโ€‹๐Ÿ‡ณโ€‹ - avatar
+ 6
Arydev , if your string is for example s = "Air", you can use s[:: - 1] to slice it backwards ๐Ÿฑ
17th Dec 2019, 10:33 AM
TheWhยกteCat ๐Ÿ‡ง๐Ÿ‡ฌ
TheWhยกteCat ๐Ÿ‡ง๐Ÿ‡ฌ - avatar
+ 3
Arydev , please look at the code. Hope now everything is clear ๐Ÿฑ https://code.sololearn.com/c7aoNwSsP98C/?ref=app
17th Dec 2019, 10:42 AM
TheWhยกteCat ๐Ÿ‡ง๐Ÿ‡ฌ
TheWhยกteCat ๐Ÿ‡ง๐Ÿ‡ฌ - avatar
+ 1
How to replace a string
17th Dec 2019, 10:33 AM
Arydev
Arydev - avatar
0
Is clear i understand it
17th Dec 2019, 11:28 AM
Arydev
Arydev - avatar
18th Dec 2019, 9:30 PM
Ipang
0
name = 'Air' # Change Air to Ria name_change = name[::-1].lower() #Change the str to lower user_output = name_change.capitalize() #Capitalize print(user_output)
20th Dec 2019, 10:25 AM
Dilji
Dilji - avatar