Question about def in Input!


File "python", line 5
def original = raw_input()
SyntaxError: invalid syntax

I was wondering why can't i use def original = raw_input() here. In which cases should i use def variable?
However, if i removed def like the 2nd image below the code works. So my codes becomes original=raw_input()

<img src="//" width="690" height="343">

Code works when i remove def

<img src="//" width="690" height="340">


original is a variable that is intended to reference a string object, the output of raw_input() that is stored in memory. It will be the user input.

def is only used to define a function. For this exercise we are not going to define any functions, so put that desire aside and set out to write inline code in the global namespace. No functions are expected by the lesson checker. Only executable code that runs from start to finish.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.