加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Print_List_of_Odd_Numbers.py 708 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nadim Akram 提交于 2020-10-05 12:57 . Update Print_List_of_Odd_Numbers.py
master
#Another best method to do this
n=map(list(int,input().split()))
odd_list=list(i for i in n if i%2!=0)
print(odd_list)
exit()
# CALCULATE NUMBER OF ODD NUMBERS
# CALCULATE NUMBER OF ODD NUMBERS WITHIN A GIVEN LIMIT
master
n = int(input("Enter the limit : ")) # user input
if n <= 0:
print("Invalid number, please enter a number greater than zero!")
else:
odd_list = [i for i in range(1,n+1,2)] # creating string with number "i"
print(odd_list) # in range from 1 till "n".
# printing odd and even number in same program
n=map(list(int,input().split()))
even=[]
odd=[]
for i in range (n):
if i%2==0:
even.append(i)
else:
odd.append(i)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化