0

Somebody help me please šŸ„ŗ

Write a program that prompts the user for the length of the list they want to input. ā€¢The user enters the list items by keyboard. The list must have integer elements as elements. ā€¢Print by console a list that contains in each element the sum of the main list ordered from smallest to largest. Example output input [457, 569, -247, 10, 5] (4+5+7)=16 / (5+6+9)=20/ (-2+4+7)=9 / (1+0)=1 /5=5 output [16,20,9,1,5] [1, 5, 9, 16, 20]

3rd Dec 2022, 7:24 PM
Dayana
Dayana - avatar
7 Answers
+ 1
First, i dont really get the meaning of the last point in your Task. The word sum confuses me. I assume, you mean to print the list ordered from smallest to greatest value... A few hints: - you initialize your list on every Iteration. So, when ever your while loop goes into a New Iteration, the list will be empty again. Maybe you'll find a better Position for this line? - after initializing the list, you redefine it, to be an integer. Maybe you rather want to add the number to the list? - instead of a manually managed while loop, you could use a for loop with a certain range. (it will work in either Way though) - after the loop, you should sort the list.
3rd Dec 2022, 9:47 PM
G B
G B - avatar
+ 1
The primary problem is transform a decimal number in a sum of own digits... Starts from here... You have a number in int form like 123 and you want get the digits sum... You can do it in different ways. - Transform the int into string, cycle it on any digit-char, transform the char in int and sum them - You can get the decimal of a number by using modulus operator, add it to sum and divide the original number by 10 (truncating in int) and repeat the process while the original number will be 0 Make sure to handle the minus at start
4th Dec 2022, 10:17 AM
KrOW
KrOW - avatar
0
Can you post your attempt?
3rd Dec 2022, 8:18 PM
KrOW
KrOW - avatar
0
longitud=int(input("Escriba la longitud de numeros que va a ingresa: ")) while longitud>0: numeros=[] numeros=int(input("Numero: ")) longitud=longitud-1 print(numeros)
3rd Dec 2022, 8:29 PM
Dayana
Dayana - avatar
0
Hi
5th Dec 2022, 2:14 PM
GAME CITY
GAME CITY - avatar
0
Hi šŸ‘‹
7th Dec 2022, 10:44 AM
Dayana
Dayana - avatar
- 1
Example input [457, 569, -247, 10, 5] (4+5+7)=16 / (5+6+9)=20/ (-2+4+7)=9 / (1+0)=1 /5=5 output [16,20,9,1,5] [1, 5, 9, 16, 20]
3rd Dec 2022, 10:05 PM
Dayana
Dayana - avatar