Write a "bouncer" program that uses a list to decide if people get in to a party or not.
$ python bouncer.py
What's your name? jeff
You're on the list...welcome to the party.
$ python bouncer.py
What's your name? valerie
Sorry, you're not on the list.
For this, you could use the in operator, or an accumulator, or what's
called a boolean flag. Assume you have two variables: a list of allowed
guest names (guestlist), and the name of a possible guest (name):
# assume they are not on the list
FOUNDNAME = False
# now check for name in guestlist, one at a time
for guest in guestlist:
if name == guest:
FOUNDNAME = True
# at this point, the boolean flag tells if they are on the list or not
if FOUNDNAME:
print("You're in...")
else:
print("Sorry...")
vim tips and tricksAll of these are from command mode, not insert mode. Hit Esc to get to command mode
before trying any of these:
shift v plus arrow keys to highlight a region< or > moves highlighted region left or rightdd deletes line (5dd deletes 5 lines)p pastes line (below line you are on)G goes to end of file (20G goes to line 20)gg goes to start of fileF9 key runs your python programA appends at the end of the current linex deletes character under cursor