3 Answers
New Answerselect=input("please enter your lucky number: ") Luck_number=[1,2,3,4,5,6,7,8,9] if(select==Luck_number[]): print("Congratulations you are the winner") else print("Sorry you did not win! Please try again") end if
8/20/2019 8:52:01 PM
Abdul Hamid Durrani3 Answers
New AnswerYou can do it like this with the in operator: if select in Luck_number: (Also, oooking at your code, you got QUITE a few things wrong. - The input needs to be converted into an integer: select = int(input()) - You don't need the parentheses for the if clause - In python, indentation is VERY important. You can't just do else print(...) you have to do: else: print(...) - Also you don't need "end if" Try to keep things clean, Ok?)
You can also:- select = int(input("please enter your lucky number: ")) Luck_number=[1,2,3,4,5,6,7,8,9] print("You winner" if select in Luck_number else "You loose! Please try again") # or print("You winner") if select in Luck_number else print("You loose! Please try again")
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message