+ 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)

17th Sep 2021, 10:14 AM
ÃÑSHÙ KHÁÑRÂ
ÃÑSHÙ KHÁÑRÂ - avatar
4 ответов
+ 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!
17th Sep 2021, 11:06 AM
Lothar
Lothar - avatar
+ 7
Can anyone tell me what is the problem in this code?
17th Sep 2021, 10:23 AM
ÃÑSHÙ KHÁÑRÂ
ÃÑSHÙ KHÁÑRÂ - avatar
+ 6
Lothar Thank you.
17th Sep 2021, 3:34 PM
ÃÑSHÙ KHÁÑRÂ
ÃÑSHÙ KHÁÑRÂ - avatar
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.
26th Sep 2022, 5:21 PM
X- FACTA
X- FACTA - avatar