-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
range updated to get odd numbers between 1 and max number
- Loading branch information
1 parent
f167a92
commit fd97ca9
Showing
1 changed file
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 comments
on commit fd97ca9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I used a different method.
for i in range(1, max):
if i % 2 != 0:
Odd.append(i)
Print(odd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a 1 to max in range to print max num if it is odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_number1=int(input("Please enter the max_number"))
odd_numbers1=[item for item in range(1,max_number1) if item%2!=0]
print(odd_numbers1)
we can check for even numbers also. right?
like for i in range(max):
if i%2!=0:
odd_numbers.append(i)