zone1=["Aldgate","Angel","Baker Street","Bank","barbarican","bayswater","Blackfriars","Bondstreet","Borough","Cannon Street","Chancery Lane","Charing cross","Covent Garden","Edgware Road","Enbankment","Euston","Euston LU","Euston Square","Farringdon","Glouchester Road","Goodge Street","Great Portland Street","Green Park","High Street Kensington","Holborn","Hyde Park Corner","Kings Cross St Pancras LU","Kings Cross","Knightsbridge","Lambeth North","Lancaster Gate","Leicester Square","liverpool street","Mansion House","Marble Arch","Marylebone","Monument","Moorgate","Notting Hill Gate","Old Street","Oxford circus","Paddington","Piccadilly circus","Pimlico","Queensway","Regent's Park","Regents park","Russell square","Shoreditch High street","Sloane square","South Kensington","Southwark","St James Park","St james's Park","St Pauls","St Paul's","Temple","Tottenham Court Road","Tower Hill","Vauxhall","Victoria","Warren Street","Waterloo","Westminister"]
a=[x.lower() for x in zone1]
zone2=["Abbey Road","All Saints","Archway","Arsenal","Barons Court","Battersea Park","Belsize Park","Bermondsey","Bethnal Green","Blackwall","Bow Church"]
b=[Q.lower() for Q in zone2]
inp= input("Enter the station you are leaving from : ")
if inp in zone1 or a:
print(inp,"is in Zone 1")
elif inp in zone2 or b:
print(inp,"is in Zone 2")

- 3,050
- 2
- 14
- 20
2 Answers
This is a problem of operator precedence.
if inp in zone1 or a:
evaluates as
if (inp in zone1) or a:
and since a is not empty, the whole expression evaluates to true.

- 2,824
- 12
- 18
-
Thank you this was really helpfull! – zain surty Jul 22 '21 at 15:51
Hello and welcome to Stackoverflow!
In your code you put the following:
if inp in zone1 or a:
This works like:
if (inp in zone1) or a:
This means this statement is always True, because a is a non-empty list and non-empty lists are evaluated as True. You put this in both if statements, so both will always be True. You can fix this by for example putting:
if inp in zone1 or inp in a:
For the future, you can make sure your question gets more and better responses by posting code inside a code block, which is explained here: https://stackoverflow.com/editing-help#syntax-highlighting
This makes it more readable for people who want to help you answer the question. I put your code in a block myself just to read what was going on:
zone1=["Aldgate","Angel","Baker Street","Bank","barbarican","bayswater","Blackfriars","Bondstreet","Borough","Cannon Street","Chancery Lane","Charing cross","Covent Garden","Edgware Road","Enbankment","Euston","Euston LU","Euston Square","Farringdon","Glouchester Road","Goodge Street","Great Portland Street","Green Park","High Street Kensington","Holborn","Hyde Park Corner","Kings Cross St Pancras LU","Kings Cross","Knightsbridge","Lambeth North","Lancaster Gate","Leicester Square","liverpool street","Mansion House","Marble Arch","Marylebone","Monument","Moorgate","Notting Hill Gate","Old Street","Oxford circus","Paddington","Piccadilly circus","Pimlico","Queensway","Regent's Park","Regents park","Russell square","Shoreditch High street","Sloane square","South Kensington","Southwark","St James Park","St james's Park","St Pauls","St Paul's","Temple","Tottenham Court Road","Tower Hill","Vauxhall","Victoria","Warren Street","Waterloo","Westminister"]
a=[x.lower() for x in zone1]
zone2=["Abbey Road","All Saints","Archway","Arsenal","Barons Court","Battersea Park","Belsize Park","Bermondsey","Bethnal Green","Blackwall","Bow Church"]
b=[Q.lower() for Q in zone2]
inp= input("Enter the station you are leaving from : ")
if inp in zone1 or a:
print(inp,"is in Zone 1")
elif inp in zone2 or b:
print(inp,"is in Zone 2")

- 373
- 1
- 4