Python Help please - creating basic functions (Ver 2.7) -


I've made progress on this question, but it always only gives the first value in the list. What am I missing in my code?

Write a function called add_numbers that receives a list parameter, it returns the total number of all the numbers in the list from the beginning, until at least 10 is not found. If no number is found to be greater than or equal to 10, then it gives the sum of all the numbers in the list.

  def add_numbers (a): total = 0 i = 0 while a [i] & lt; 10: total = total + a [i] i = i + 1 total return   

is the second one:

Write a function called make-list which receives Does a numeric parameter give it a number of data less than 0 to the numeric parameter.

I know how to do this if all numbers are asked for numbers, but the list is confused.

The last one is:

Write a function called count_bricks which receives a numerical parameter. This function gives the number of bricks in the pyramid which is high in many levels. Each level of the pyramid has another brick than its level above it.

It is not sure where it is even started.

Thanks in advance for help, this is not a homework, it's just a sample quiz filled with questions - these are those that I was not able to answer.

You should return outside the loop or return the value to the first move.

  def add_numbers (a): total = 0 i = 0 while a [i] & lt; 10 and I LT; LAN (A): total = total + one [i] i = i + 1 return total # should be outside of return loop   

signal for second question:

  1. one

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -