learn-python icon indicating copy to clipboard operation
learn-python copied to clipboard

Update magic8.py

Open Bhavyyadav25 opened this issue 3 years ago • 3 comments

Bhavyyadav25 avatar Jul 27 '22 14:07 Bhavyyadav25

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jul 27 '22 14:07 CLAassistant

magic8.zip

Morning all,

Just made a little change to standard magic8 on codecademy. Thanks

kochiops avatar Aug 06 '22 03:08 kochiops

my Code :)

import random name = "Alex" question = "Can i be a hero?" answer = "" random_number = random.randint(1, 9)

if random_number == 1: answer = "Yes - definitely." elif random_number == 2: answer = "It is decidedly so." elif random_number == 3: answer = "Without a doubt." elif random_number == 4: answer = "Reply hazy, try again." elif random_number == 5: answer = "Ask again later." elif random_number == 6: answer = "Better not tell you now." elif random_number == 7: answer = "My sources say no." elif random_number == 8: answer = "Outlook not so good." elif random_number == 9: answer = "Very doubtful." else: answer = "Error"

if question == "": print("You must ask a question.")

if len(name) >= 1 and len(question) >= 1: print(name + " asks: " + question) elif len(name) == 0 and len(question) >= 1: print("Question: " + question)

if len(name) >= 1 and len(question) >= 1 or len(name) == 0 and len(question) >= 1: print("Magic 8-Ball's answer: " + answer)

AlexWithRelax avatar Aug 12 '22 18:08 AlexWithRelax