Why Can't Return Assignment Statement
In IDLE, I write a function and intend to return a value. but it can't return >>> def grade(value): if value > 100: return (value=100) if value <0:
Solution 1:
In a return statement, only an expression can come after the "return".
return_stmt ::= "return" [expression_list]
An assignment is a statement. You can't put a statement after "return", because a statement isn't an expression.
Consider skipping the assignment entirely. Just return
will suffice:
return100
Post a Comment for "Why Can't Return Assignment Statement"