Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

I'm dealing with an infinite loop. What do I need to do to fix it?

$
0
0

I'm dealing with an infinite loop here. It keeps on printing: " You are over your budget!". I don't know what's causing it or how to fix it. `

def main():    monthly_budget = int(input("Enter the amount you budget for the month:", ))    expenses = int(input("Enter your monthly expenses:", ))    while expenses == expenses:        print(expenses)        amount_left = monthly_budget - expenses        if amount_left > monthly_budget:            print("You are under your budget! ")        else:            amount_left < monthly_budget            print("You are over your budget!") main()

I tried adding a for loop to have it get printed 1 time but I have trouble there as well

I think it might be if statements are causing the issue.I'm still learning Python so I might be making a simple mistake.


Viewing all articles
Browse latest Browse all 13921

Trending Articles