方法1
s = input()
if s.count('A') <= 1 and s.count('LLL') == 0:
print(True)
else:
print(False)
方法2
s = input()
print(s.count('A') <= 1 and s.count('LLL') == 0)
实现
hello westos python
python westos hello
print(' '.join(input().split()[::-1]))
替换字符
如
They are students
aeiou
Thy r stdnts
"""
# 定义两个接收用户输入的变量
str1 = input('str1:')
str2 = input('str2:')
# 遍历整个字符串
for i in str1:
for j in str2:
if i == j:
break
# end 指定结束符,在for语句体中表示不换行输出
else:
print(i,end='')
s1 = input('s1:')
s2 = input('s2:')
# 遍历字符串s1
for i in s1:
# 依次判断s1中的每个字符是否在s2中
if i in s2:
# replace 表示替换;
# 将s1中与s2中相同的所有字符,替换为空字符
s1 = s1.replace(i,'')
print(s1)