Skip to content

Learn Python

  • Python
  • Cyber Security Basics
Learn Python
  • Python

     index(), count(), reverse(), sort()

    Byadmin August 7, 2025August 7, 2025

    Python List Methods: index(), count(), reverse(), sort() Let’s explore these essential list methods with multiple examples for each. 1. index() Method Returns the index of the first occurrence of a value. Examples: python # Example 1: Basic usage fruits = [‘apple’, ‘banana’, ‘cherry’, ‘banana’] print(fruits.index(‘banana’)) # Output: 1 # Example 2: With start parameter print(fruits.index(‘banana’, 2)) # Output: 3 (starts searching…

    Read More  index(), count(), reverse(), sort()Continue

  • Python

    pop(), remove(), clear(), and del 

    Byadmin August 6, 2025August 6, 2025

    pop(), remove(), clear(), and del with 5 examples each, including slicing where applicable: 1. pop([index]) Removes and returns the item at the given index. If no index is given, it removes the last item. Examples: 2. remove(x) Removes the first occurrence of the specified value x. Raises ValueError if not found. Examples: 3. clear() Removes all elements from the list, making it empty. Examples: 4. del Statement Deletes elements by index or slice (not a method, but a…

    Read More pop(), remove(), clear(), and del Continue

  • Python

    append(), extend(), and insert() methods in Python lists

    Byadmin August 6, 2025August 6, 2025

    append(), extend(), and insert() methods in Python lists, along with slicing where applicable. 1. append() Method Adds a single element to the end of the list. Examples: 2. extend() Method Adds multiple elements (iterable items) to the end of the list. Examples: 3. insert() Method Inserts an element at a specific position. Examples: Key Differences: Method Modifies List? Adds Single/Multiple Elements? Position append() ✅ Yes Single element (even if it’s a list) End…

    Read More append(), extend(), and insert() methods in Python listsContinue

  • Python

    complete list of list methods in python

    Byadmin August 6, 2025August 7, 2025

    1. Adding Elements 2. Removing Elements 3. Accessing Elements 4. Sorting & Reversing 5. Copying & Joining 6. List Comparison & Operations Note: Python List copy() Method with Examples The copy() method in Python returns a shallow copy of a list. This means it creates a new list with the same elements as the original, but the new list…

    Read More complete list of list methods in pythonContinue

  • Python

     List operators,List Traversals

    Byadmin August 4, 2025August 4, 2025

    In Python, lists are ordered, mutable collections that support various operations. Here are the key list operators along with four basic examples: List Operators in Python 4 Basic Examples 1. Concatenation (+) Combines two lists into one. python list1 = [1, 2, 3] list2 = [4, 5, 6] combined = list1 + list2 print(combined) # Output: [1, 2, 3,…

    Read More  List operators,List TraversalsContinue

  • Python

    Negative slicing in Python lists

    Byadmin August 2, 2025August 2, 2025

    Negative slicing in Python lists lets you access elements from the end of the list. It’s a handy way to get a portion of a list without knowing its exact length. In negative slicing, you use negative numbers as indices. The index -1 refers to the last element, -2 to the second to last, and…

    Read More Negative slicing in Python listsContinue

  • Python

    Indexing and Slicing for Writing (Modifying) Lists in Python

    Byadmin August 2, 2025August 2, 2025

    Indexing and Slicing for Writing (Modifying) Lists in Python Indexing and slicing aren’t just for reading lists – they’re powerful tools for modifying lists as well. Let’s explore how to use them to change list contents with detailed examples. 1. Modifying Single Elements (Indexing for Writing) You can directly assign new values to specific indices. Example 1:…

    Read More Indexing and Slicing for Writing (Modifying) Lists in PythonContinue

  • Python

    Indexing and Slicing in Python Lists Read

    Byadmin August 2, 2025August 2, 2025

    Indexing and Slicing in Python Lists Read Indexing and slicing are fundamental operations to access and extract elements from a list in Python. 1. Indexing (Accessing Single Elements) Example 1: Basic Indexing python fruits = [“apple”, “banana”, “cherry”, “date”, “fig”] # Positive indexing print(fruits[0]) # “apple” (1st element) print(fruits[2]) # “cherry” (3rd element) # Negative indexing print(fruits[-1]) # “fig”…

    Read More Indexing and Slicing in Python Lists ReadContinue

  • Python

    Linear vs. Scalar,Homogeneous vs. Heterogeneous 

    Byadmin August 2, 2025August 2, 2025

    Linear vs. Scalar Data Types in Python In programming, data types can be categorized based on how they store and organize data. Two important classifications are scalar (atomic) types and linear (compound) types. 1. Scalar (Atomic) Data Types 2. Linear (Compound/Sequential) Data Types Key Differences Between Scalar and Linear Data Types Feature Scalar (Atomic) Linear (Compound) Stores Single…

    Read More Linear vs. Scalar,Homogeneous vs. Heterogeneous Continue

  • Python

    Create lists

    Byadmin August 2, 2025August 2, 2025

    In Python, there are multiple ways to create lists, depending on the use case. Below are the most common methods: 1. Direct Initialization (Using Square Brackets []) The simplest way to create a list is by enclosing elements in square brackets []. Example: python empty_list = [] numbers = [1, 2, 3, 4] mixed_list = [1, “hello”, 3.14,…

    Read More Create listsContinue

Page navigation

Previous PagePrevious 1 … 11 12 13 14 15 … 19 Next PageNext

© 2026 Learn Python - WordPress Theme by Kadence WP

Scroll to top
  • Python
  • Cyber Security Basics