0
I didn't understand what is .append, and lambda
4 Antworten
+ 6
.append is used to add items to the end of a list.
Lambda is known as a anonymous function which is used to create small functions without using def etc...
Lambda doesn't has a name so it is called as a anonymous function
+ 5
Go through the lessons again you will understand
+ 1
Use append method to add new element at the end of list
lst = [2,3,4]
lst.append(5)
lambda or anonymous function is another way to create function fastly with short syntax and return value after the colon.before colon you set condition or parameters
lambda x:x*2
0
.append() is a method that adds a SINGLE element to the END of a list.
Ex:
List = ['a', 1, 'b', 2, 'c', 3, 'd']
List.append(4)
print(List)
>>> ['a', 1, 'b', 2, 'c', 3, 'd', 4]
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/methods/list/append
https://www.w3schools.com/python/ref_list_append.asp
https://realpython.com/python-string-split-concatenate-join/
lambda is an anonymous function, this means a function that does not need to be defined, give it a name.
square = (lambda x, n : x**n) (2, 8)
print(bin(square))
>>> 0b100000000
https://realpython.com/python-lambda/
https://www.geeksforgeeks.org/python-lambda-anonymous-functions-filter-map-reduce/