# #5.第五次 字符串分割、索引和切片练习题
# 1.理解索引这个会在之后经常用到
#
# 2.定义字符串、例如:str1 = 'http://www.jianshu.com/u/a987b338c373'字符串内容为自己的首页连接,输出自己的简书id(u/之后的内容--a987b338c373)
str1 = 'http://www.jianshu.com/u/dc4c97565c2e'
str2 = str1.split("/")
print('ID=', str2[4])
# 3.设s = "abcdefg", 则下列值为
# s[3] 'd'
# s[2:4] 'cd'
# s[:5] 'abcde'
# s[3:] 'defg'
# s[::-1] 'gfedcba'
# s[::2] 'aceg'
# 4.定义列表:list1 = [1,2,3,4,5,6,7],则下列值为
list1 = [1,2,3,4,5,6,7]
# list1[3]
print(list1[3])
# list1[2:4]
print(list1[2:4])
# list1[:5]
print(list1[:5])
# list1[3:]
print(list1[3:])
# list1[::-1]
print(list1[::-1])
# list1[2:4]
print(list1[2:4])
# 5.定义元组:touple1 = (1,2,3,4,5,6,7),则下列值为
touple1 = (1,2,3,4,5,6,7)
# touple1[3] touple1[2:4]
print(touple1[3], touple1[2:4])
# touple1[:5] touple1[3:]
print(touple1[:5], touple1[3:])
# touple1[::-1] touple1[::2]
print(touple1[::-1], touple1[::2])