dimanche 9 mai 2021

Print different output based on integer without conditional statements

I'm trying to make a program takes 1 or 0 as an input, if the user chose one the program will print “open” , if 0 it will print out “close” , but I’m trying not to use conditional statements , i tried to use the while loop but it didn’t work

x=int(input("enter 0 or 1"))
while x==1:
    print("open")
while x==0: 
    print("close")

Aucun commentaire:

Enregistrer un commentaire