+ 2

# Snap crackle pop help

I don't understand what is wrong number_rk = input() sound = [] for qty in number_rk: qty = int(qty) if qty %3 == 0 : sound.append ("Pop") elif qty%2==0: sound.append ("Crackle") else: sound.append ("Snap") print(" ".join(sound))

28th Nov 2023, 7:23 AM
Ling Chin Ung
6 ответов
+ 2
You have six bowls of Rice Krispies in front of you, and they make different noises when you pour milk over them based on the total number of Rice Krispies in each bowl. If a bowl has a number of Rice Krispies that is divisible by 3, it will make a Pop sound. If it is not divisible by 3 but is odd it will make a Snap sound. If it is not divisible by 3, but it is even, it will make a Crackle sound. Task: Based on the quantities in each bowl, output the noise that they make. Input Format: You receive 6 integers and each integer represents the number of Rice Krispies in your bowls. Output Format: You should output a string with the sounds made by each bowl separated by spaces in the order that they were input. Sample Input: 18 5 100 25 40 24 Sample Output: Pop Snap Crackle Snap Crackle Pop
28th Nov 2023, 1:01 PM
Ling Chin Ung
+ 2
Your code only receive one input, but the code coach gives you six inputs. You need to find a way to collection all the inputs first.
28th Nov 2023, 1:06 PM
Wong Hei Ming
+ 2
Hint: You could change the beginning of your code and receive the 6 integers in a loop and then all will work fine.
28th Nov 2023, 1:34 PM
JaScript
+ 2
Thank you guys solved it finally
28th Nov 2023, 1:52 PM
Ling Chin Ung
+ 1
What is the description of this task?
28th Nov 2023, 7:41 AM
JaScript
+ 1
Let's say number_rk received a string "3" as an input... for qty in number_rk: qty = int("3") >>> qty = 3 It will append "Pop" into a list variable sound, and the for loop is finished. You asked for a space (' ') join the list of sound, but the list only contains 1 element. There is nothing to join and print "Pop" only.
28th Nov 2023, 9:11 AM
Wong Hei Ming
Актуальное сегодня
chorter code