0
How to find the first letter of a input string
I tried this : x = input() print(x[1])
7 Answers
+ 7
Python uses 0-based indexing.
print(x[0])
+ 6
This also will do the job:
print(input()[0])
+ 2
Hey hey here counting starts from 0 not 1 đ¤
+ 1
In python indexes start at 0. It should be x[0]
0
Thanks
0
the regex here is ^\w where the ^ indicates to look if it happens at the start of the string and then the \w is for any a-z, A-Z, and _
- 1
look into regex. I use regex to do this stuff. something like
import re
x = input(ââ)
y = re.findall(â^\wâ, x)
print(y)