标签:语言 print img inf sort bsp 网上 字母 flag
从 第3章-8 字符串逆序 开始
1.
n = str(input())
n1=n[::-1]
print(n1)
2.
不是很好做这道题,自己还是C语言的思维,网上几乎也找不到什么答案
s = input()
idx = s.find("#")
s = s[:idx]
ss = s[:idx]
s_16 = "0123456789ABCDEFabcdef"
for c in s:
if c not in s_16:
s = s.replace(c, ‘‘)
flag = 0
for c in ss:
if c in s_16:
flag = ss.find(c)
break
if ‘-‘ in ss[:flag]:
s = ‘-‘ + s
if len(s) == 0:
num_10 = 0
else:
num_10 = int(s, 16)
print(num_10)
3.
滤掉5个字母,还有空格和感叹号
a=input()
count=0
for i in range(0,len(a)):
if(a[i]!=‘A‘ and a[i]!=‘E‘ and a[i]!=‘I‘ and a[i]!=‘O‘ and a[i]!=‘U‘ and a[i]!=‘!‘ and a[i]!=‘ ‘ and ‘A‘<=a[i]<=‘Z‘):
count=count+1
print(count)
4.
我还在思考字符串怎么排序,发现其实之前做过的sort()函数可以用来无差别排序,一下子就简单了:
ls =list(input().split())
ls1=sorted(ls)
print("After sorted")
for i in ls1:
print(i)
标签:语言 print img inf sort bsp 网上 字母 flag
原文地址:https://www.cnblogs.com/echoDetected/p/12286479.html