fb pixel

Nested if statements

Conditional statements can contain a block of code that is arbitrary. It can contain print statements, it can contain variable assignments and it can even contain other if/else blocks.
if name == 'Anna':
	print('Hello, Anna')
	salary = 1000
	if not 18 <= age <= 30:
		print('You are not Anna, stop lying')
		salary = -1
else:
	if name == 'Bob':
		print('How are you doing, Bob?')
		salary = 900
	else:
		print('I probably do not know you...')
This is one example of how the nesting of conditional statements could be written. It can go even deeper:
if a:
	...
else:
	if b:
		...
	else:
		if c:
			if d:
				...
			else:
				...
So, blocks of code are indented with 4 spaces, and the body of an if statement appears “inside” the statement. The body of an if/else statement can be arbitrary and can contain other if/else statements.
 

Challenge

Write a program that would input a name and if the name is Alice, would greet Alice with Hey there! and otherwise would print I don't know you. The program should also read the salary Alice wants and should print Sounds good if the salary is below 10000, otherwise, it should print Let's discuss this a little.
Input
Output
Alice 20000
Hey there! Let's discuss this a little
Bob 20000
I don't know you
 
To check your solution you need to sign in
Sign in to continue