I want to take 5 values and add 1+2+3+4+5 = 15 <- I want to make this value [1,5] as a list Is it possible to enter only the character value by using the list function...? Or is it because there is only one value? Anyway, you can change it to str and then change it to map function, but there is an error when you use it in the repetitive sentence. You have to keep adding the value separated by the list...Is there a way to divide this all at once?
arr = []
result = 1
num = int (input ("repeated numeric")
for i in range(num):
num2 = int (input ("numeric input")
arr.append(num2)
print(arr)
for j in arr:
result += j
result = list(str(result))
result = list(map(int, result))
print(result)
The question itself is not fully understood. I don't understand that it should be done especially in repetitive sentences.
>>> list(map(int, list(str(15))))
[1, 5]
I'm not sure about the rules.
If you add up from 1 to 15, it's 120 If it's 1, 20, it's 3.
def sum_of_item(number):
L = list(map(int, list(str(number))))
print(L)
sum_L = sum(L)
print(sum_L)
if sum_L >= 10:
sum_of_item(sum_L)
sum_L = sum(range(1, 11))
print(sum_L)
sum_of_item(sum_L)
55
[5, 5]
10
[1, 0]
1
If the range is 1 and 16,
120
[1, 2, 0]
3
554 PHP ssh2_scp_send fails to send files as intended
548 Uncaught (inpromise) Error on Electron: An object could not be cloned
551 Understanding How to Configure Google API Key
545 GDB gets version error when attempting to debug with the Presense SDK (IDE)
758 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.