Commit c667a98f by BellCodeEditor

save project

parent d36f911f
s = 'aabbbccccbbd'
dict2 = {}
for i in s:
if i not in dict2:
dict2[i] = s.count(i)
s1 = ''
for k,v in dict2.items():
s1 += k + str(v)
print(s1)
\ No newline at end of file
s = 'Welome to Beijing'
s1 = s.split(' ')
s1.reverse()
print(' '.join(s1))
\ No newline at end of file
str=input("请输入一个字符串:\n")
A=""
B=""
for i in str[::2]:
A=A+i
print("下标为偶数的字符串:")
print(A)
for j in str[1::2]:
B=B+j
print("下标为奇数的字符串:")
print(B)
C=A+B
print("合并后的字符串:")
print(C)
\ No newline at end of file
str1 = "ayjAYJabcdefghf"
new = {}
str2 = str1.lower()
for j in str2:
if j in new:
new[j] += 1
else:
new[j] = 1
print(new)
\ No newline at end of file
str=input("请输入一个字符串:\n")
str1=str[0:-1]
str3=str[-1]+str1
print("后移一位的新字符串为:%s"%str3)
\ No newline at end of file
list=['1','2','3','4','5','6','7','8','9']
length=len(list)
print("字符串中间位置的数字为:%s"%list[int((length-1)/2)])
\ No newline at end of file
list=[1,1,1,2,2,3,4,4,4,5,5]
for i in list:
if list.count(i)>1:
list.remove(i)
print("删除重复元素后:%s"%list)
\ No newline at end of file
goods = {'可口可乐':3,'旺仔牛奶':4,'农夫山泉':1,'辣条':3,'巴西烤肉':2,'果冻':4,'乐事':5,'奥利奥':10,'巧克力':6}
goods.pop("农夫山泉")
print(goods)
s = 'HelloMyWorld'
str = []
for i in range(len(s)):
if 'A' <= s[i] <='Z' and i != 0:
str.append(' ')
str.append(s[i])
print(''.join(str))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment