0

I am currenty teaching myself Python using the book called Learn Python 3 the Hard Way. I've reached to exercise 14 (Prompting and Passing) and I have some code which needs to be displayed in PowerShell but something is not working here. I'll post the code below following the explanation.

from sys import argv

script, user_name = argv
prompt = '>'

print (f"Hi {user_name}, I'm the {script} script.")
print ("I'd like to ask you a few questions.")
print (f"Do you like me {user_name}?")
likes = input(prompt)

print (f"Where do you like {user_name}?")
lives = input(prompt)

print(f"What kind of computers do you have?")
computer = input(prompt)

print(f"""
Alright, so you said {likes} about liking me.
You live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
""")

So, PowerShell won't print nothing because I receive the following error:

File "14.py", line 6
    print (f"Hi {user_name}, I'm the {script} script.")
                                                 ^
SyntaxError: invalid syntax

I can't find the solution. I know it's because of string formatting which doesn't work and I previously had another exercise with string formatting but I've managed to go around the error and print what I wanted. But still, it's annoying and I'm trying to find the answer. Could someone give me a hint?

Aran-Fey
  • 35,525
  • 9
  • 94
  • 135

0 Answers0