PYTHON TUTORIAL - UNPACKING ARGUMENT

 



UNPACKING ARGUMENT


 Pertimbangkan situasi dimana kita memiliki fungsi yang menerima argumen.

- Contoh 

def healt(age, apple_ate, cigs):
    total = (100-age) + (apple_ate * 3.5) - (cigs*2)
    print(total)

nic = [16, 10, 0]

healt(nic[0], nic[1], nic[2])
healt(*nic)

- Output 

119.0
119.0

No comments:

Powered by Blogger.