18F / an_introduction_to_python

An introduction to Python - https://www.digitalgov.gov/event/online-intro-to-python/
10 stars 8 forks source link

I'm struggling with hacker rank question if/else #3

Closed EricSchles closed 7 years ago

EricSchles commented 7 years ago

Hi! I'm having trouble with this question:

https://www.hackerrank.com/challenges/py-if-else

if __name__ == '__main__':
    n = int(input())

This is my example code, it's failing to produce the right output.

Here are the things I've tried

EricSchles commented 7 years ago

Here's the answer:

if __name__ == '__main__':
    n = int(input())
    if n % 2 == 1:
        print("Weird")
    else:
        if n in list(range(6, 21)):
            print("Weird")
        else:
            print("Not Weird")