jeudi 25 juin 2020

Random Fortune Cookie assignemtn [closed]

I am new to Java and I have been assigned by my professor a random fortune cookie assignment which will generate one random random fortune cookie saying out of 10 sayings and will loop as long as the user doesn't enter "0".

Here is the code I have for now but for some reason I keep on getting invalid syntax on line 26 on the statement "if userInput = 0".

Any help will be appreciated, thanks. Below is my code.

import random
global fortunes
fortunes = ["Good things come to those who wait.",
            "Patience is a virtue.",
            "The early bird gets the worm.",
            "A wise man once said, everything in its own time and place.",
            "Fortune cookies rarely share fortunes.",
            "A pleasant surprise is waiting for you.",
            "A smile is your personal welcome mat.",
            "A smile is your personal welcome mat.",
            "A soft voice may be awfully persuasive.",
            "Adventure can be real happiness."]

def init():
    global fortunes
    userInput = input("Welcome to the Fortune Teller, Enter 0 to quite or anything else to get your fortune ")
    if userInput = 0
        done()

def loop():
    global fortunes
    if userInput = 0 
        done()
    else:
        print(random.choice(fortunes))
        
def done():
    print("Thanks for playing")
    
def main():
    global radius
    init()
    while userInput != 0
        loop()
    done()
main()






Aucun commentaire:

Enregistrer un commentaire