Haber si me podéis echar una mano con este ejercicio que estoy atascado y no doy con la solución
Citar
Create a function addNumbers(x) that takes a number as an argument and adds all the integers between 1 and the number (inclusive) and returns the total number.
Examples
>>> addNumbers(10)
55
>>> addNumbers(1)
1
Y empieza asi el ejercicio :
def addNumbers(num):
total = 0
i = 1
while
Examples
>>> addNumbers(10)
55
>>> addNumbers(1)
1
Y empieza asi el ejercicio :
def addNumbers(num):
total = 0
i = 1
while
Conozco el ciclo indefinido while, pero no logro tener una idea para aplicarlo, he echo el ejercicio usando for sin problema, pero tiene que ser con while
Código
def addNumbers(num): total=0 for num in range(num+1): total=total+num return total
Saludos!!!