胖小妹
胖小妹
全部文章
分类
归档
标签
去牛客网
登录
/
注册
胖小妹的博客
全部文章
(共7篇)
题解 | #创建集合#
#创建一个列表记录输入字符串,以空格间隔 list1 = input().split() #创建一个新列表记录去重之后的列表 list2 = set(list1) #排序输出 print(sorted(list2))
Python3
2022-08-08
2
333
题解 | #子串的数量#
patten = input() print(patten.count('Niu'))
Python3
2022-08-08
6
316
题解 | #用列表实现队列#
#初始化列表 queue = [1, 2, 3, 4, 5] #使用pop函数去除队首元素 queue.pop(0) print(queue) #使用pop函数去除队首元素 queue.pop(0) print(queue) #使用append函数添加输入元素至队尾,注意input输入是str格式...
Python3
2022-08-02
0
246
题解 | #密码游戏#
#创建一个数组,获取输入的四位数 list1 =int(input()) #获取4位数中每一位的值 first = list1//1000 second = (list1//100)%10 third = (list1//10)%10 fourth = list1 % 10 #创建一个临时数组ar...
Python3
数组
2022-08-02
0
221
题解 | #有序的列表#
#创建一个依次包含字符串'P'、'y'、't'、'h'、'o'和'n'的列表my_list my_list = ['P','y','t','h','o','n'] #使用sorted函数对列表my_list进行临时排序,输出 print(sorted(my_list)) #输出原始列表 print(...
Python3
2022-08-02
68
876
题解 | #淘汰排名最后的学生#
本题是如何使用删除函数 del #del语句可以删除任何位置处的列表元素 remove #remove方法可根据值删除元素如果不知道要删除元素在列表中的位置时可用remove...
Python3
2022-08-01
5
303
题解 | #删除好友#
#新建一个列表存储输入的好友 list1 = input() #列表中字符串以空格间隔 list2 = list1.split(" ") #创建一个对象存储输入删除的好友 name = input() #从列表中删除 list2.remove(name) print(list2)
Python3
2022-07-29
0
271