python - Python: How to print all numbers except the multiples of 3
问题描述
In trying to print all numbers except multiples of 3
until 10, this program does not shows any output:
a = 1
for a in range (1,10) :
if a % 3 == 0:
continue
a+=1
print (a)
a+=1
解决方案
只需简化为:
for a in range(1,10):
if a % 3 != 0:
print(a)
推荐阅读
- bash - SED 未向 .csv 文件添加第一行
- apache-spark - 从 s3 将外部 jars 加载到 Zeppelin
- javascript - 尽管数据已解析,Javascript 未决承诺仍返回承诺
- asp.net-mvc - ASP.NET Web 应用程序中的工具栏:单例方法总是返回 null
- windows - 与 Windows 机器建立 ansible 连接
- r - R rbind: concatenate each element of a nested list
- python - 类型错误:字符串索引必须是整数
- object-detection - 训练网络做检测任务
- css - 更改输入或文本区域内的字体颜色
- java - Convert char to hexadecimal by encoding in Java