Home > database >  Is there any way to print a specific letter of string without indexing?
Is there any way to print a specific letter of string without indexing?

Time:12-19

Write a Python program that reads a line from the user and prints the first character of the given input.

Sample Input Sample Output
The quick brown fox jumps over the lazy dog T
Python is an interpreted language P
N=('Python is an interpreted language ')
Print(N[0])

CodePudding user response:

I guess you could

print(next(iter(N)))

It creates an iterator from string N. And next(it) gives the next element in the iteration, which, the first time, is the first element.

  • Related