Answers for "nested loops python"

2

dict comprehension python

# dict comprehension we use same logic, with a difference of key:value pair
# {key:value for i in list}

fruits = ["apple", "banana", "cherry"]
print({f: len(f) for f in fruits})

#output
{'apple': 5, 'banana': 6, 'cherry': 6}
Posted by: Guest on December-29-2020
0

Nested For loop in Python

# outer loop
for i in range(1, 11):
    # nested loop
    # to iterate from 1 to 10
    for j in range(1, 11):
        # print multiplication
        print(i * j, end=' ')
    print()
Posted by: Guest on November-18-2021

Python Answers by Framework

Browse Popular Code Answers by Language