update
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
name = str(input('enter your name to check length : '))
|
||||
# len()不止能够计算str的长度 它可以返回所有容器的长度
|
||||
print('{0} name length is {1}'.format(name, len(name)))
|
||||
|
@@ -1,4 +1,5 @@
|
||||
first_name = str(input('Enter your first name in lower-case : '))
|
||||
surname = str(input('Enter your surname in lower-case : '))
|
||||
# title就是把word转换为标题形式
|
||||
compact = first_name.title() + ' ' + surname.title()
|
||||
print(compact)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
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 : '))
|
||||
# 截断字符串包含start位不包含end位
|
||||
print('this is the 1st. line \n {0} \n and this is truncated {1}'.format(rhyme, rhyme[start:end]))
|
||||
|
Reference in New Issue
Block a user