题解 | #截取字符串#
截取字符串
https://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
# 1.提取输入的字符串和长度
str1=input()
num=int(input())
str2=''
count=0
# 2.遍历字符串。当小于要提取的长度,逐个字符提取放在str2
while count<num:
str2=str2+str1[count]
count=count+1
print(str2)
查看3道真题和解析