lang = "Python"
first_letter = lang[0]
print(first_letter)
#source code --> clcoding.com
Explanation:
Define the Variable:
lang = "Python" stores the string "Python" in the variable lang.
Use Indexing to Access the First Letter:
In Python, indexing starts from 0.
lang[0] refers to the first character of "Python", which is "P".
Print the Extracted Letter:
print(first_letter) outputs the first letter "P".
Output:
P
0 Comments:
Post a Comment