Shrivardhana
Shrivardhana

Reputation: 203

I am getting the following error : ValueError: invalid literal for int() with base 10

n = int(input('enter no.'))
if (n % 2) != 0 or n > 6 and n < 20 == True:
print('weird')
else:
print('not weird')

if I run the above code, I get the above error.

Upvotes: 0

Views: 42

Answers (2)

Swastik Mohapatra
Swastik Mohapatra

Reputation: 77

Try this:

if (n % 2) != 0 or n > 6 and n < 20:
   print('weird')
else:
   print('not weird')

Your original code was not properly indented.

Also, please check your logical criterion. It seems a bit weird.

Upvotes: 1

Avneet
Avneet

Reputation: 67

There is an indentation issue with this is what I can say, otherwise I am getting the perfect results.

Try this :

n = int(input('enter no.'))
if (n % 2) != 0 or n > 6 and n < 20 == True:
    print('weird')
else:
    print('not weird')

Upvotes: 1

Related Questions