[Tutor] (no subject)

Collisio Adolebitque collisio at net-devops.com
Tue Feb 11 01:56:43 EST 2020


username = 'user3'
usernames = ['user1', 'user2', 'user3', 'user4']


def check_list_for_pattern(user: str, users: list) -> bool:
    return True if user in users else False


print(check_list_for_pattern(username, usernames))

________________________________
From: Tutor <tutor-bounces+collisio=net-devops.com at python.org> on behalf of Alfie Lee <alfielee21 at outlook.com>
Sent: Monday, February 10, 2020 7:36:05 PM
To: tutor at python.org <tutor at python.org>
Subject: [Tutor] (no subject)



Sent from Mail<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D550986&data=02%7C01%7C%7Ce5bb51c2eace41581d6b08d7ae6301d5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637169612558658843&sdata=dMaSX0cTnKJjTIelAPFJKMBVHh8Krzuqm8Jx0SvS0f8%3D&reserved=0> for Windows 10

If say I had a variable called ‘username’, and a list of usernames called ‘usernames’; how would I write it so that the programme will check if that username is in the usernames list?
this would be using an if statement if possible.

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&data=02%7C01%7C%7Ce5bb51c2eace41581d6b08d7ae6301d5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637169612558658843&sdata=5mOwzWcFQD1FEwF5DQ%2BXHI8FrGeETMFzEIU%2BjZkyY5U%3D&reserved=0


More information about the Tutor mailing list