Issue
SyntaxError: 'return' outside function, any solution for this? using jupyter notebook
string='"hello"'
for i in string:
if i=='\"':
d=string.replace("\"","")
return d
else:
return string
Solution
a return statement must be inside a function
for instance:
def my_function():
string='"hello"'
for i in string:
if i=='\"':
d=string.replace("\"","")
return d
else:
return string
This solves and explains your error. furas comment says:
"Your code makes no sense - use directly single line string = string.replace(""","") – furas"
Answered By - Ricardo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.