dimanche 20 mai 2018

TypeError: unsupported operand type(s) for %: 'range' and 'int'

Write a Python program to find numbers between 120 and 200 which are divisible by 7 and multiples of 5 without using a "for loop".

I tried to work it out this way...

x = range(120, 200)
if x % 7 == 0 and x % 5 == 0:
    print(x)

But rather I do get this error. What could I be missing out?

Traceback (most recent call last):
File "C:\Users\User\Desktop\skillshare-code\if else statements\4.py", line 
    11, in <module>
if x % 7 == 0 and x % 5 == 0:
TypeError: unsupported operand type(s) for %: 'range' and 'int'

Aucun commentaire:

Enregistrer un commentaire