牛客350787991号
牛客350787991号
全部文章
分类
归档
标签
去牛客网
登录
/
注册
牛客350787991号的博客
全部文章
(共63篇)
题解 | #使用字典计数#
list1 = list(input()) list2 = [list1.count(i) for i in list1] print(dict(zip(list1,list2))) 在给定的代码中,list1 能够自动去重的原因是由于列表推导式和 dict() 函数的使用。 首先,list1 =...
2023-09-25
0
297
题解 | #字典新增#
dict1 = { "a": ["apple", "abandon", "ant"], "b": ["banana", "bee", "...
2023-09-25
0
297
题解 | #查字典#
dict1 = { "a": ["apple", "abandon", "ant"], "b": ["banana", "bee", "...
2023-09-25
0
258
题解 | #生成字典#
key = input().split() value = input().split() dict1 = dict(zip(key,value))#zip()函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表.得到列表,dict()函数将列表转化为字典...
2023-09-25
0
224
题解 | #遍历字典#
operators_dict = {'<':'less than','==':'equal'}#建立字典, dict = {'Key':'value','key':'value'......} print('Here is the original dict:') for x in sorte...
2023-09-25
0
215
题解 | #增加元组的长度#
x = tuple(range(1,6)) print(x) print(len(x)) y = tuple(range(6,11)) print(x+y) print(len(x+y))
2023-09-24
0
253
题解 | #输出前三同学的成绩#
x = tuple(input().split()) y = slice(0,3) result = x[y] print(result) 在这个例子中,我们使用 split() 方法将输入的字符串分割成多个单词,并使用 tuple() 函数将单词列表转换为元组。然后,我们使用切片 y 来获取前三个...
2023-09-24
1
289
题解 | #运动会双人项目#
print(tuple([input(),input()])) tuple里面只能有一个元素,把两个str打包成一个list
2023-09-24
2
233
题解 | #跳过列表的某个元素#
for i in range(1,16): if i == 13: continue else: print(i,end=' ') 当使用 Python 中的 print 函数时,你可以使用 sep 和 end 参数来控制输出的格式。 sep ...
2023-09-24
19
351
题解 | #格式化清单#
stack = ['apple', 'ice cream', 'watermelon', 'chips', 'hotdogs', 'hotpot'] while len(stack)>0: stack.pop() print(stack) 需要注意的是第二行代码while后面...
2023-09-24
0
260
首页
上一页
1
2
3
4
5
6
7
下一页
末页