Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Argumentos de longitud variable
- """
- def sumar(numeros):
- total = 0
- for numero in numeros:
- total += numero
- return total
- print(sumar([1,2,3,4,5,6]))
- def sumar2(*args):
- total = 0
- for n in args:
- total += n
- return total
- print(sumar2(1,2,3))
- def sumar3(**kwargs):
- total = 0
- for n in kwargs:
- total += kwargs[n]
- return total
- print(sumar3(a=1, b=2, c=3))
- """
- # podría hacer esto:
- def todo(x,y,z,k=11,*args, w=23, **kwargs):
- print(x)
- print(y)
- print(z)
- print(args)
- print(w)
- print(kwargs)
- todo(1,2,2,10,11,12, a=1000,b=2000)
Advertisement
Add Comment
Please, Sign In to add comment