[英]Is there any way to print a specific letter of string without indexing?
Write a Python program that reads a line from the user and prints the first character of the given input.编写一个 Python 程序,从用户那里读取一行并打印给定输入的第一个字符。
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])
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.它从字符串 N 创建一个迭代器。
next(it)
给出迭代中的下一个元素,第一次是第一个元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.