-3

I'm creating a program which I have to put a number and when I run the program, the solution should be the day for that number. But I don't know how to do. The program I did was this:

num = 4
if(num = 1)
    print('Monday')
elif(num = 2)
    print('Tuesday')
elif(num = 3)
    print('Wednesday')
elif(num = 4)
    print('Thursday')
elif(num = 5)
    print('Friday')
elif(num = 6)
    print('Sunday')
elif(num = 7)
    print('Saturday')
elif(num < 1)
    print('Put a number between 1 and 7')
else(num > 7)
    print('Put a number between 1 and 7')
jeffhale
  • 3,759
  • 7
  • 40
  • 56
  • 1
    that should work fine? whats wrong with it? – Joran Beasley Feb 13 '21 at 21:27
  • Could you be more specific about what issue you have? What errors do you receive when running the posted code? See also [How do I ask and answer homework questions](https://meta.stackoverflow.com/q/334822?). – im_baby Feb 13 '21 at 21:30
  • If your problem is the python code not running, the if statements should be for example `if(num == 1):`. So change to `==` and add `:`. As per previous comments though, it would help if you were more specific on the problem. – James Cockbain Feb 13 '21 at 21:54

2 Answers2

0
num = 0
while num <= 7:
    num += 1
    if num == 1:
        print('Monday')
    elif num == 2:
        print('Tuesday')
    elif num == 3:
        print('Wednesday')
    elif num == 4:
        print('Thursday')
    elif num == 5:
        print('Friday')
    elif num == 6:
        print('Saturday')
    elif num == 7:
        print('Sunday')
Kevin Meyer
  • 2,816
  • 4
  • 21
  • 33
404th
  • 85
  • 7
0

In python, for statements like if, for, etc. You have to add : at the end of it. And for comparing (for equal) you have to use == and not =

num = 4
if(num == 1):
    print('Monday')
elif num == 2:
    print('Tuesday')

.....

You can compare without parenthesis and it will work too.

Edgar Magallon
  • 556
  • 2
  • 7
  • 15