Python slaag 'n lys as 'n argument
Verlaat 'n lys as 'n argument
Jy kan enige datatipe argument na 'n funksie stuur (string, nommer, lys, woordeboek ens.), en dit sal as dieselfde datatipe binne die funksie hanteer word.
As jy byvoorbeeld 'n Lys as 'n argument stuur, sal dit steeds 'n Lys wees wanneer dit die funksie bereik:
Voorbeeld
def my_function(food):
for x in food:
print(x)
fruits = ["apple", "banana", "cherry"]
my_function(fruits)