Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help
#1
who can figure out this

Using a “while loop” ask the user for a number and add it to a list if number is even and to a different list if number is odd. Keep asking the user for a number until he says “I’m bored” and doesn’t want to give you any more numbers.
L=["1","2","3","5" ]
Odd= ["1"]
while True:
print("hello")
number = int(input("give me a number? ")
if number == L % 2:
print(L)
elif number in L % 1 == 0:
print(Odd)
elif "im bored":
print("ok thanks for your help!")

output when ran is:


L=["1","2","3","5" ]
Odd= ["1"]
while True:
print("hello")
number = int(input("give me a number? ")
if number == L % 2:
print(L)
elif number in L % 1 == 0:
print(Odd)
elif "im bored":
print("ok thanks for your help!")
File "<ipython-input-7-c06cac4d7836>", line 6
if number == L % 2:
^
SyntaxError: invalid syntax
Reply
#2
You missed a close paren on the previous line.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020