66.4k views
5 votes
In Python, how would you print only the first character of a string?

User CcQpein
by
4.2k points

2 Answers

3 votes

Answer:

>>> s = "Hello"

>>> print(s[0])

H

User Selvakumar Esra
by
4.3k points
6 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 Jee Seok Yoon
by
4.6k points