0
While problem, need help with the code!
Please help me to understand what is the problem, the question is : You have a magic box that doubles the count of items you put, in every day. The given program takes the initial count of the items and the number of days as input. Task Write a program to calculate and output items' count on the last day. Sample Input 3 2 Sample Output 12 Explanation Day 1: 6 (3*2) Day 2: 12 (6*2) The code I was doing: items = int(input()) days = int(input()) #your code goes here i=0 while i<=days: items *=2 i+=1 print(items)
2 Respuestas
+ 3
You're starting from i=0, so it should be
while i<days
Anyway, python has an exponent operator: **
So you can just do
items * 2**days
0
Many thanks!