How to remove the first character of a string that's in a list? [PYTHON]

Viewed 57

I would like to remove the ["flow", "flappy", "flirtify"] first character from every single index in this array, but I don't know how. I tried almost everything but it still doesn't work. Any suggestions?

4 Answers
first_char_removed = [word[1:] for word in original_list]

In the future, I would recommend posting your code attempts

to remove the first character of a string you can just use string[1:] who return you the same string without the first character.

see code example below :


for myword in myWordsArray:
  print(myword[1:])
[word[1:] for word in ["flow", "flappy", "flirtify"]]

you can see how to do it for a single string, and then use list comprehension

The simplest way would probably be list comprehension

l = [e[1:] for e in ["flow", "flappy", "flirtify"]]
Related