gpt4 book ai didi

python - 翻译伪代码回文

转载 作者:太空宇宙 更新时间:2023-11-04 05:34:44 24 4
gpt4 key购买 nike

<分区>

我有需要翻译的伪代码:

Prompt the user to enter a string and call it s.
Let l be the length of string
For i from 0 upto l-1:
print s[0:i]
For i from 0 upto l-1:
print s[i:l]
Print a closing statement

这是我的翻译:

 def main():

s=(input("Please enter a string: "))
L=len(s)

for i in [0,L-1]:
print (s[0:i])

for i in [0,L-1]:
print(s[i:L])

print("This program is complete!")

main()

但是,代码打印不正确。有人可以帮我找到我的错误吗?谢谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com