Return outside function error in Python

DonArmy 0 Reputation points
2024-04-01T10:26:15.2833333+00:00

I have tried every possible way that i know to resolve this, still getting the same response. please i need help!

Here is the code

def system_login(username, password):

allowed_list = ["remi", "joshua", "tayo", "debbie", "ezekiel", "augustine", "michael"]

if username in allowed_list and len(password) >=6:

return "Welcome, you're allowed to access the system"
```else:

```sql
return("This username does not exist in our system") or ("The password you entered is too short")
```Here is the error message:


```ruby
 Cell In[1], line 6
    return "Welcome, you're allowed to access the system"
    ^
SyntaxError: 'return' outside function
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,073 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 111.1K Reputation points MVP
    2024-04-01T10:45:50.4633333+00:00

    You hadUser's image But you are asking a question about Python? Maybe you are not in the right place? Python is not a Microsoft product.

    Anyway, it seems that you have failed to indent the if statement. Recall that indentation is significant in Python!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.