Day 11: Python Syntax: Basic Concepts —Looping Through Different Data Types python example.

Day 11: Python Syntax: Basic Concepts —Looping Through Different Data Types python example.

Python in 30 Days: A Practical and Theoretical Approach for Beginner.

image 37 Simply Creative Minds

List Example

fruits = ["apple", "banana", "cherry"]

for fruit in fruits:
    print(fruit)
image 26 Simply Creative Minds

Tuple

coordinates = (10, 20, 30)
for point in coordinates:
 print(point)
image 27 Simply Creative Minds

Dictionary

person = {"name": "tom", "age": 30, "city": "dallas"}

# Loop through keys
for key in person:
    print(key)

# Loop through values
for value in person.values():
    print(value)

# Loop through key-value pairs
for key, value in person.items():
    print(f"{key}: {value}")
image 28 Simply Creative Minds

Set

unique_numbers = {1, 2, 3, 4}

for number in unique_numbers:
    print(number)
image 29 Simply Creative Minds

String

text = "Hello"

for char in text:
    print(char)
image 30 Simply Creative Minds

Happy Coding and Stay Tuned 🙂

Kind is always cool !!!

Share knowledge to gain knowledge !!!!

Be kind and treat people with respect !!!

If you find my blog helpful, then please subscribe, claps and follow to support 🙂

image 35 Simply Creative Minds

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *