What is the best way to remove 1st letter from string? [Python] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the best way to remove 1st letter from string? [Python]

25th Jul 2021, 6:25 AM
Bhavik Mahalle
Bhavik Mahalle - avatar
4 Answers
+ 3
Adding more to NotAPythonNinja's answer or for more list slicing tutorials. https://code.sololearn.com/cAQBZ3dHmbKW/?ref=app
25th Jul 2021, 6:54 AM
Rohit Kh
Rohit Kh - avatar
+ 2
myString = "Some words go here." myString = myString[1:] print (myString) #>>ome words go here.
27th Jul 2021, 2:46 AM
CowsEatGrass
CowsEatGrass - avatar
+ 1
It is another way to remove first letter from string string = "string" s = list(string) string = "".join(s[1:]) print(string) # it outputs "tring" DHANANJAY PATEL
25th Jul 2021, 7:35 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
0
Strong are immutable i.e Instead, you assign a new string from the sliced string like this : name = "Sulaiman" s_name = name[1:] print(name). #this print Sulaimon print(s_name). #this print ulaiman
26th Jul 2021, 5:53 PM
olakayCoder1
olakayCoder1 - avatar