Define a function named add

Assignment Help Basic Computer Science
Reference no: EM132183933

Define a function named add_from_one_again(st) which receives a list containing digits only (at least one digit, and all digits >0, no need to validate)  and returns a number as illustrated by the following examples

When the list is 

[5,2,3]

the resulting number should be:

(1+2+3+4+5) + (1+2) + (1+2+3)  = 24

When the list is 

[3,2,5]

the resulting number should be:

(1+2+3) + (1+2) + (1+2+3+4+5) = 24

When the list is

[4,2,2]

the resulting number should be:

(1+2+3+4) + (1+2) + (1+2) = 16

As an example, the following code fragment:

lst = [5,2,3]

print(add_from_one_again(lst))

should produce the output:

24

Language: python

I have this so far, but doesn't work:

def add_from_one_again(st):

collect_sum = 0

for i in st:

i = int(i)

collect_sum += sum(len(i))

return collect_sum

Reference no: EM132183933

What competitive advantage does technology give to business

What competitive advantage does technology give to business? How does aging hardware affect this advantage? What is the importance of organizational decision roles to technolo

Radio frequency identification technology

With the evolution of radio frequency identification technology (RFID) instead of universal product code (UPC), how will this capability make the production grow and improve

Express the angle with respect to the tangential velocity

Express the angle with respect to the tangential velocity vector (ie, +90° points radially out). (Points : 5) A) 10.9 m/s2 at -75° B) 10.9 m/s2 at +75° C) 37.9 m/s2 at -75°

Packet sniffer in situation

Provide one (1) example of a situation where the use of a packet sniffer might be justified. Explain why you believe it would be okay to use a packet sniffer in this situati

Next performance improvement project

Describe where this hospital needs the most improvement and why. Describe what you think the most important opportunity for improvement is. Recommend where to focus the next p

Characteristics of the spot market

1. In a short essay, discuss the characteristics of the spot market. 2. What is configuration? Briefly list and discuss the factors that influence value chain configuration.

Risk assessmentbelow is the global finance

Risk assessmentBelow is the Global Finance, Inc. (GFI) network diagram. A hypothetical company, GFI has grown rapidly this past year and implemented a number of network device

The program by three-dimensional array

Write a small program that will read in 52 cards from a file, shuffle the cards, print the unshuffled deck to the screen, and print the shuffled deck into new file. The unshuf

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd