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

Questions Cloud

How can a person protect the privacy in the digital world : Cyberstalking can take place through any form of electronic communication, to include email, cell phones (text messaging), social network sites.
What are the current generational differences in attitudes : Based on Internet research of reputable sources, what are the current generational differences in attitudes toward the role of religion in America?
What are the three types of sparklines options : In this Week's reading and prep work, you learned about the Sparklines feature in Excel. What are the three types of Sparklines options in Excel.
Construct a quarterly binomial model : The stock has an expected return of 8% per year and return volatility of 20% per year. Construct a 2-period quarterly binomial model for the stock
Define a function named add : 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)
Employer dress code impact the organizational culture : What is your employer’s dress code? How does an employer’s dress code impact the organizational culture?
Prepare financial statements of small and medium scale : MAA261 - Financial Accounting - prepare financial statements of small and medium scale business - Understand the nature of the accounting information systems
How does quantum cryptography work : Compare and contrast quantum cryptography and traditional cryptography. How does quantum cryptography work?
What amount must joyce include in gross income for december : Joyce is self-employed. She uses the calendar year and the cash method of accounting. What amount must Joyce include in gross income for December

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What kind of a binary tree is the heap

What kind of a binary tree is the heap? Explain different operations of heaps. Compare heaps to binary search trees in term of efficiencies of main operations.

  Significant tool to help discover security breaches

Auditing is an significant tool to help discover security breaches, yet many organizations do not implement auditing practices.

  What is the purpose of prices in a market system

What is the purpose of prices in a market system? Is there a better way to allocate products?

  Networking forensics using wireshark

"Networking Forensics using Wireshark" readings this week focus on monitoring network traffic in real-time.

  The mutex and condition portions of messagesystem

the mutex and condition portions of MessageSystem

  Conflict of interest between an it worker self-interest

Describe a situation in which there could be a conflict of interest between an IT worker's self-interest and the interests of a client.

  What is the difference between inputstream and filereader

WHat is the difference between InputStream and FileReader?

  Why target overlooked or ignored the red flag(s).

Conclude the main reasons why the attack on Target occurred. Give your opinion as to whether or not the attack was mainly due to the poor infrastructure or the inability of management to act accordingly. Justify your response.

  Identify the hardware list at least five different hardware

Identify the hardware you have on your computer and catagorize each piece as input, output, or both. (2) List at least five different pieces of hardware with at least one of each category.

  What does address space mean in a memory block

Construct a 16-bit memory space using gated D latches as the basic building blocks. Do not forget to add control circuitry for WE.

  Execute a graphic application

Develop, test, and execute a graphic application using Java.Create a Java application.

  Your company has a projects f for investment

Your company has a projects F for investment. The company needs to borrow to finance these projects. Other details of the projects are as follows:

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