How could I write this without getting a syntax error? [closed]

1

I am trying to calculate numbers in a range that when divided between 2 3 4 5 and 6, give rest 1 2 3 4 and 5, respectively. The syntax error is found when trying to use the module and match it to the rest that I want to obtain.

n = 0

while n < 439:

    if n%2=1 and n%3=2 and n%4=3 and n%5=4 and n%6=5
        print (n)
    else:
        n += 1

The syntax error is encountered when trying to do n% 2 = 1

    
asked by Fernando 17.05.2018 в 00:59
source

1 answer

-1

Your errors are as follows

  • The operator = means assignment ie for example a = 3
  • If you want to make the comparison the operator you should use is == which implies checking if the value on the left is equal to the one on the right
  • Also python requires that after the opening of the if 2 points are placed

    n = 0
    
    while n < 439:
    
        if n%2==1 and n%3==2 and n%4==3 and n%5==4 and n%6==5:
            print (n)
        else:
            n += 1
    
        
    answered by 17.05.2018 / 01:08
    source