Help with code

hello! so basically I have a question on a if greater than… here’s the problem == “Within the following elif statement, write an inner if...else that checks if the transfer amount is greater than the savings balance. If the amount is indeed greater, in the else statement, assign transaction_status to the variable trans_error + str(checking_balance) .”
so I thought myself well it’s going to be if amount >= saving_balance, ------- but it turns out this is not the case its actually ---------- if amount <= savings_balance: but doesn’t <= mean less than or equal to? I thought I was trying to see if the amount is greater than savings balance so >=. but according to the solution page on my jupyter notebook its <=

Please someone help clarifying this for me
Thx!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

Hi there.

I think the question is worded poorly, but the reason for the expectation you’d use <= is here:

write an inner if...else that checks if the transfer amount is greater than the savings balance. If the amount is indeed greater, in the else statement, assign transaction_status to the variable trans_error + str(checking_balance) .”

They’re asking you to create an if...else to check if the user is trying to transfer more money than they have, but you’re being asked to flag the error specifically in the else branch of the conditional.

If the else will run in cases where the transfer amount exceeds the available balance, logically the if branch must cover the case where there is sufficient cash to complete the transfer.

Does that help? :slight_smile:

1 Like

sorry but im still confused

Apologies if this is incorrect, please consider linking to the lesson/project. Without seeing the question I think it’s just using the logic the opposite way round. For a quick example-

x = 3

if x <= 4:
    print('yes')
else:
    print('no')

# or... the other way round-
if x > 4:
    print('no')
else:
    print('yes')
# results are basically equivalent even if the code isn't
1 Like