-1

Hello I'm a noob and just started using python so I wanted to have fun using raw_input , adding random questions and stuff but I came across an error. It says the invalid syntax is ". I've been trying to put it to different places but didnt succeed I'm sorry if this is a really dumb question but can someone help me out.

Heres a line with the error

print " Oh okay then %s . You came from %s , right? Oh i see you came here to %s" % (name,so,fun)

It's pointing at the closing " next to %s

I'm using atom

edit: heres the error

 File "C:\Users\USER\AppData\Local\atom\app-1.26.1\Testing.py", line 10
print " Oh okay then %s . You came from %s , right? Oh i see you came here %s. " % (name, so, fun)
                                                                               ^

SyntaxError: invalid syntax

Heres the full code :

name = raw_input("Hello whats your name?")
so = raw_input("From where did you come from")
fun = raw_input("Interesting, why did you come here?")
#start the sentence with "for"


print " Oh okay then %s . You came from %s , right? Oh i see you came here %s. " % (name, so, fun)

If I can't use raw_input what can I use then? I learned with using that.

AA Shakil
  • 538
  • 4
  • 14
Marko
  • 1
  • 2
  • Look at str.format() instead. – Anton vBR May 05 '18 at 13:03
  • 2
    There's no syntax error in that line of code. Please post a [mcve] - enough code to reproduce the problem, and the complete traceback. – Aran-Fey May 05 '18 at 13:03
  • 5
    You didn't show us how you defined `name`, `so` , or `fun`, but I guess you're trying to run that code on Python 3. That code's valid on Python 2, but not Python 3. OTOH, `raw_input` doesn't exist in Python 3, so your question is a little puzzling. – PM 2Ring May 05 '18 at 13:03
  • @PM2Ring you're correct, it can be posted as answer instead of comment – Andrii Maletskyi May 05 '18 at 13:05
  • @AndriyMaletsky Well, I don't know if this question really needs a full answer. And I'd like to resolve the `raw_input` mystery before I commit myself to writing a proper answer. – PM 2Ring May 05 '18 at 13:07
  • Oh im sorry ill edit my question right now. – Marko May 05 '18 at 13:08
  • Possible duplicate of [Syntax error on print with Python 3](https://stackoverflow.com/questions/826948/syntax-error-on-print-with-python-3) – Georgy May 05 '18 at 13:48

1 Answers1

2

I fixed the issue by putting brackets around the whole thing like

print (" Oh okay then %s . You came from %s , right? Oh i see you came here to %s" % (name,so,fun))

Also I believe that raw_input was replaced with 'input()'.

Sam lemonts
  • 114
  • 1
  • 7
  • Why is this downvoted, I have no issue removing it just want to know for future reference – Sam lemonts May 05 '18 at 13:11
  • Thank you it worked !! Im sorry for this dumb question ill try harder to fix my own problem. – Marko May 05 '18 at 13:17
  • why did you put quotes around "so" and "fun"? Those are clearly defined as variables in the question and making them string literals changes the behavior – avigil May 05 '18 at 13:44