Reputation: 33
I'm trying to write a program where I am adding 0.165 to the variable weight
. I am trying to repeat this 15 times. However, it is crucial that weight
is constantly being added to 0.165 15 times, e.g. 13.365, 13.53, 13.495, etc.
How would I accomplish this? Sorry, I am kind of new to this whole python coding, so please point out any excess mistakes from my code.
weight=int(input("Enter your weight"))
newweight=weight+1
othernewweight=newweight*0.165
count=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15']
for x in range(0,15):
print("year", count+0", "othernewweight+0.65")
Upvotes: 3
Views: 1019
Reputation: 4151
This will ask you for input weight
in float
type, then repeat 0.165 addition to weight
for 15 times
weight=float(input("Enter your weight"))
for x in range(15):
weight += 0.165
print (round(weight,3)) #to print 3 decimals
Output :
Enter your weight 13.2
13.365
13.53
13.695
13.86
14.025
14.19
14.355
14.52
14.685
14.85
15.015
15.18
15.345
15.51
15.675
Upvotes: 3
Reputation: 88
There are a few problems here. First, you have put count + 0
and othernewweight+0.65
inside of quotes, so they are printed as text, literally "othernewweight+0.65", instead of the values you are looking for. You also need to make sure you are actually updating the variable. weight+0.165
doesn't do anything unless you store it somewhere as weight=weight+0.165
or weight += 0.165
for short.
weight=int(input("Enter your weight"))
for x in range(15):
weight += 0.165
print(weight)
Upvotes: 2