1 Star 0 Fork 0

fanyangchu/PythonCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Print_List_of_Odd_Numbers.py 712 Bytes
一键复制 编辑 原始数据 按行查看 历史
# 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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fanych/pythoncode.git
git@gitee.com:fanych/pythoncode.git
fanych
pythoncode
PythonCode
master

搜索帮助