jeudi 26 avril 2018

IF statement ignoring keyboard input

I have been trying to run a program using keyboard input to decide whether or not to run the program and the if statement is ignoring the input and always defaults to the else statement. Here is my code.

import random
import time
import sys

print("Do you want to run the program? Yes/No")
ans = sys.stdin.readline()

time.sleep(1)

if ans == "Yes" or ans == "yes":

    '''Body of IF statement'''

else:
    print("Alright, have a great day!")

Aucun commentaire:

Enregistrer un commentaire