In this example, you will learn how to append a list to a list in Python. Append List to List Python Program Example The following Python program will create a fruit list and a vegetable list; then, it will append ...
vinish.ai Latest Articles
Built-in methods of Dictionary in Python
Shibulen() This method is used to return the length of the dictionary. That is, the number of items (key-value pairs) Example: dict1={‘name’:’john’,’course’:’B.Tech’,’Stipen’:9000} print(len(dict1)) Output: 3 clear() This method to delete all entries in the dictionary. Example: dict1={‘name’:’john’,’course’:’B.Tech’,’Stipen’:9000} dict1.clear() print(dict1) Output: ...
Built-In methods of List in Python
Shibuappend() This method is used to append an element to the list. Example: num_list=[1,2,3,4,5] num_list.append(6) print(num_list) Output: [1, 2, 3, 4, 5, 6] count() This method is used to count the number of times an element appears in the list. ...
Built-In String Methods and Functions in Python
Shibucapitalize() This function is used to capitalize the first letter of the string. Example: str=”hello world” print(str.capitalize()) Output: Hello world count(str, beg, end) This function is used to count the number of times str occurs in a string. We can ...
Name of Module, Making our own modules in Python
ShibuName of Module Every module has a name. We can find the name of a module by using the __name__attribute of the module. Actually, for every standalone program written by the user, the name of the module is _main_. Example: ...
Modules in Python
ShibuIn Python, modules are pre-written pieces of code that are used to perform common tasks like generating random numbers, performing mathematical operations, etc. It allows us to reuse one or more functions in a program, even in the programs in ...
Recursive Function in Python
ShibuIn Python, a recursive function is defined as a function that calls itself to solve a smaller version of its task until a final call is made, which does not require a call to itself. Every recursive solution has two ...
Lambda Function in Python
ShibuLambda functions are throw-away functions, i.e., they are just needed; they have been created and can be used anywhere a function is required. Lambda functions are so-called because they are not declared as other functions using the keyword def. They ...
Defining Function in Python
ShibuFunction definition with required arguments: For required arguments, the arguments are passed to a function in correct positional order. Also, the number of arguments in the function call is exactly matched with the number of arguments specified in the function ...
Variable scope and Lifetime in Python
ShibuIn Python, we cannot just access any variable from any part of our program. Some of the variables may not even exist for the entire duration of the program. In which part of the program we can access a variable ...