题解 | #成绩输入输出#
成绩输入输出
https://www.nowcoder.com/practice/eb49750ef0de47168c21761de086d97c
scores=list(input().split())
for index,score in enumerate(scores):
print(f"score{index+1}={score}",end="")
if (index) < (len(scores) -1):
print(",",end="")
print("\n")
enumerate() 函数是 Python 内置函数之一,用于在迭代过程中同时获取元素的索引和值。这个函数返回一个生成器对象,每次迭代会返回一个包含索引和对应值的元组。这在需要同时访问索引和元素值的场景中非常有用。——来自Chatgpt
查看1道真题和解析