TristanSld

functions with variable-length arguments

Feb 14th, 2014
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def carp(*dizelge):
  5.     a = 1
  6.     for i in dizelge:
  7.         a *= i
  8.     print a, "\n"
  9. carp(2,5,8,10,11)
  10. #veya
  11. a=2,5,8,10,11
  12. carp(*a)
  13.  
  14. print "\n\n"
  15.  
  16. def kayit_ekle(isim, soyisim, sehir, meslek, tel, adres):
  17.     kayit = {}
  18.     kayit["%s %s" %(isim, soyisim)] = [sehir, meslek, tel, adres]
  19.     print "Bağlantı bilgileri kayıtlara eklendi!\n"
  20.     for k, v in kayit.items():
  21.         print k
  22.         print "-"*len(k)
  23.     for i in v:
  24.         print i
  25.  
  26. a=["Bayram","Güçlü","Antalya","Öğrenci","0242 123 45 67","Finike"]
  27. kayit_ekle(*a)
RAW Paste Data