함수
-
[Python] 함수의 매개변수의 수를 자유롭게 받아보자 *argsPython 2021. 11. 4. 04:34
*agrs = agruments = 매개변수 매개변수를 상황에 따라 n개를 받을수 있다. arguments는 tuple 형태로 들어온다. == 순서가 있고, 수정이 안된다 food_list = [] def fav_food(my_food_list, *foods): if isinstance(my_food_list, list): for food in foods: my_food_list.append(food) fav_food(food_list, "pie", "cake", "juice", "beef") print(food_list) => ['pie', 'cake', 'juice', 'beef'] food_list = [] def fav_food(*foods, food_list): if isinstance(food..