How to check strings with if else ? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

How to check strings with if else ?

friend = "Maung Maung" if friend == "MaungMaung": print("Welcome Sir From My VIP Room") else: print("Welcome Sir From My Coffee Shop")

11th Feb 2019, 1:35 PM
Phyoe Min Thant
Phyoe Min Thant - avatar
10 Respuestas
+ 2
Use indentation. if friend == "MaungMaung": print("VIP Room") else: print("Coffee Shop")
11th Feb 2019, 1:50 PM
Diego
Diego - avatar
+ 1
Oh I see. I need format. It is alright now. That's why.
12th Feb 2019, 12:51 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
+ 1
Thank you very much. It takes me a day to work out.
12th Feb 2019, 12:59 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
0
On my laptop, there is an error pop up "expected an indented block". Why?
12th Feb 2019, 12:23 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
0
Nope. I put it right and it is still showing.
12th Feb 2019, 12:26 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
0
Try with this. friend = "Maung Maung" if friend == "Maung Maung": print("Welcome Sir From My VIP Room") else: print("Welcome Sir From My Coffee Shop") Maybe your IDE doesn't allow spaces to indent. If it doesn't work please share a link to your code.
12th Feb 2019, 12:30 AM
Diego
Diego - avatar
0
The code you shared is like the one you originally had, which needs to be indented.
12th Feb 2019, 12:40 AM
Diego
Diego - avatar
0
indented? How shall I do?
12th Feb 2019, 12:47 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
12th Feb 2019, 12:47 AM
Phyoe Min Thant
Phyoe Min Thant - avatar