python-by-example-150-chall.../challenges20-26/challenge-023.py

6 lines
316 B
Python
Raw Permalink Normal View History

2019-07-17 14:56:46 +08:00
rhyme = str(input('Enter the 1st. line of nursery rhyme : '))
start = int(input('Enter start number for display : '))
end = int(input('Enter end number for display : '))
2025-05-26 06:49:34 +08:00
# 截断字符串包含start位不包含end位
2019-07-17 14:56:46 +08:00
print('this is the 1st. line \n {0} \n and this is truncated {1}'.format(rhyme, rhyme[start:end]))