Python 3:切韵

新手上路,请多包涵

通过将 rhyme_lyric 从 start_index 切片到 end_index 来为 sub_lyric 分配 ‘cow’。给定程序的示例输出:

奶牛

start_index = 4
end_index = 7
rhyme_lyric = 'The cow jumped over the moon.'
sub_lyric = rhyme_lyric''' Your solution goes here '''
print(sub_lyric)

原文由 Jexler Caranto 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 496
1 个回答

我一直在检查这里给出的所有解决方案并进行了简单的分析。对我有用的解决方案是使用以下代码行:

sub_lyric = rhyme_lyric[start_index:end_index]

原文由 Data Scientist 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
Stack Overflow 翻译
子站问答
访问
宣传栏