+ 4
How to remove first character from string ?
I am solving a problem so I have to remove first Character from words but I have no idea. Anyone tell me how to remove.
17 Réponses
0
You can use: del a[-1]
+ 8
Pawan Kumar
x = ["aapple","bbanana","ccat","ddonkey"]
y = [ i[1:] for i in x]
print(y)
#apple,banana,cat,donkey
+ 5
I think it can be something like:
a = input()
print(a[1:])
Hope that's helpful!
+ 3
a="hello"
Indexing
________
print(a[0]) // 'h'
Slicing
_______
print(a[1:]) //"ello"
+ 3
It is not possible!
A string is immutable, all you can do is create another string not having first char.
Choose one of the proposals given .
+ 1
Use this simple code -
print(str(input())[1:])
0
Thanks Friends
0
Finally I have solved the problem.
- 1
a = "string"
a = a[1:]
print(a)
- 1
a = input()
r = a.replace(a[-1], '')
print(r)
- 1
Rostislav Khalilov and Md Sayed and Abhay I want to remove first character of list string.
I mean a list where values are string.
Ok
- 1
Ok let me try frist
- 1
Yo, just use a[0] to get the first index of a.
- 1
You can use this method...
a = "PMurad" (or any string)
a = a[1:]
print(a)
Your output will be "Murad" (1st character removed)
- 1
You can use replace() method.
str = "Ahmed"
NewStr= str.replace("A","")
print (NewStr)
Output:
hmed
- 2
A##