Python 3.x 通过迭代检查字符串
我输入一个单词。我想检查单词内容是否为字母“a”。 最后使用Python 3.x 通过迭代检查字符串,python-3.x,loops,Python 3.x,Loops,我输入一个单词。我想检查单词内容是否为字母“a”。 最后使用print() 问题是我不知道在continue 我想要的结果如下: 例1: 苹果 字:a 例2: 家 没有:a 假设您需要使用for循环,而不是只检查str1中的'a',请使用a for else if 'a' in input(): print('word:a') else: print('without:a') 在“继续”之后,无法在循环中运行代码。。。这就是continue语句的要点 if 'a' in inp
print()
问题是我不知道在continue
我想要的结果如下:
例1:
苹果
字:a
例2:
家
没有:a
假设您需要使用for循环,而不是只检查str1中的
'a',请使用a for else
if 'a' in input():
print('word:a')
else:
print('without:a')
在“继续”之后,无法在循环中运行代码。。。这就是continue语句的要点
if 'a' in input():
print('word:a')
else:
print('without:a')
str1=input()
for i in str1:
if i=='a'
print('word:a')
break
else:
print('without:a')
print("word:a" if 'a' in input() else "without a")