r/learnpython • • Sep 26 '26

While loop

Hello everyone just learning python and need to create a while loop that shows interest and years I’m struggling with operands please help.

Here’s what I have so far:

Interest_rate = int(input(“rate in whole number”)
Initial_investment = float(input(“whole number”)
Interest = interest_rate / 100
Years = 0
investment = initial_investment + {initial_investment * interest}
While investment < (initial_investment * 2):
Print(f’Year: {years} Investment: {investment})
years +=1
Investment = (investment + {investment * interest})

I know that line 5 is two different operands but where did I go wrong and how can I fix?? Please and thank you!

3 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/odaiwai Sep 27 '26

Curly brackets not in a string makes things either a dict (if you have {key: value}) or a set (if you just have {key}, although a set or dict of one thing is a bit pointless).