Thursday, 5 September 2013

Python3: Why is this syntax invalid?

Python3: Why is this syntax invalid?

I am new to computer programing and am trying to modify an existing
program. The original program is:
def main():
print("hello, world!")
x = int(input("give me a number! "))
print(x+1,"is my favorite number!!")
main()
I have to modify it to say "hello, name" and say that x squared is the
fav. number.
This is what I typed into vim:
def main()
x = int(input("What is your name?")
print("hello,"x)
main()
def main():
y = int(input("give me a number!"))
print(y**2, "is my favorite number!!")
main()
When I run python3 it responds with:
File "hello.py", line 1
def main()
^
SyntaxError: invalid syntax
What does this mean and how do I fix it?

No comments:

Post a Comment