362,091 views
9 votes
9 votes
In Python, how would you print only the first character of a string?

User BigHandsome
by
2.7k points

2 Answers

21 votes
21 votes

Answer:

>>> s = "Hello"

>>> print(s[0])

H

User Dante Romero
by
2.8k points
16 votes
16 votes

Answer:

mylist[0][0]

Step-by-step explanation:

String indexing in Python is zero-based: the first character in the string has index 0 , the next has index 1 , and so on

User Milean
by
3.1k points