Python Forum
Useless Newbee - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Useless Newbee (/thread-24786.html)



Useless Newbee - craigpusey - Mar-04-2020

Hi I've just started trying to teach myself Python using one of the "for Dummies" books, I'me using VS Code through Anaconda running Python 3.7. I've attempted to make a Magic 8 Ball Program and I'm showing no errors in my code yet it doesn't run. It says there is a syntax error.

import random
question = input("Ask the Magic 8 Ball a Question")
answer = random.randint(1,8)
if answer == 1:
    print("Definately")
elif answer == 2:
    print("Looking good")
elif answer == 3:
    print("You can count on it")
elif answer == 4:
    print("Ask me again leter")
elif answer == 5:
    print("I'm not sure you really want ot know")
elif answer == 6:
    print("I wouldn't bet money on it")
elif answer == 7:
    print(" Not a chance")
elif answer == 8:
    print("I've heard that's a no")
else:
    print("That's not a question")
print ("The End")
This is the response in terminal:

>>> & C:/Users/my user/AppData/Local/Continuum/anaconda3/python.exe "c:/Users/my user/Google Drive/Python/Code Library/Magic 8 Ball.py"
File "<stdin>", line 1
& C:/Users/my users/AppData/Local/Continuum/anaconda3/python.exe "c:/Users/my users/Google Drive/Python/Code Library/Magic 8 Ball.py"
^
SyntaxError: invalid syntax


I'm sure it's something simple and basic, however that is where my knowledge is currently. Any help would be great fully received.


RE: Useless Newbee - buran - Mar-04-2020

>>> indicates you are in python interactive mode. you must run your code from terminal.
read https://python-forum.io/Thread-Anaconda-and-other-ways-to-run-Python
https://python-forum.io/Thread-How-to-Execute-python-code
Also read how to convert huge if block into dict: https://python-forum.io/Thread-if-structure-converted-to-dictionary


RE: Useless Newbee - craigpusey - Mar-04-2020

right got it, now all i need to do is figure out the formatting, inserting spaces and new lines ect.