python 序列类型的方法10题
my_lst = [1, 2, 3, 6]
my_lst.append(9)
print(my_lst)
def count_elements(my_list2):
return len(my_list2)
my_list3 = [1, 2, 3, 4, 5]
print(count_elements(my_list3))
my_str = "hello world"
reversed_str = my_str[::-1]
print(reversed_str)
aa = ['1', '2', '78']
bb = ['11', '22', '33']
aa.extend(bb)
print(aa)
my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
for index, value in enumerate(my_list):
print(f'Index: {index}, Value: {value}')
def max_element(input_list):
return max(input_list)
test_list = [3, 99, 1, 6, 2, 5]
print(max_element(test_list))
s = {2, 8, 1, 5, 2}
print(s)
my_set = {1, 2, 2, 3, 4, 4, 5}
unique_set = set(my_set)
print(unique_set)
words = input("请输入你要打印的单词,用空格分隔:").split()
sorted_words = sorted(words)
print(sorted_words)
lst2 = ['hello', 'world', '1', '2', '3']
lst2.pop()
print(lst2)