+ 8
Can anyone help me in the code coach problem 26.2 in Python Core?
while Loops 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) Use *= operator to multiply the count of the items by 2 in each iteration. My code: items = int(input()) days = int(input()) while days > 0: days -= 1 items = days + items * 2 print(items)
4 Answers
+ 5
ANSHU KHANRA | Solohelper ,
2 issues, see your code with comments:
....
while days > 0:
days -= 1
items = items * 2 # formula reworked
print(items) # output should done only once, not in each iteration. removed indentation
happy coding and good success!
+ 7
Can anyone tell me what is the problem in this code?
+ 6
Lothar
Thank you.
0
The moment you realized Sololearn won't be enough to teach you python (and I have a paid account)
When you get stuck in one of the practices you don't have anything pointing you to videos or posts, that will help you learn.
All you have is the comment section which more than likley just gives you the answers. (which doesn't help you to learn)
There should be an option of videos and posts FOR STUDENTS to go futher their education exactly where they get stuck.