Python List Tutorial

#Problem 1: Print the following Output from the 2 given lists.
#10 5 10 7
#20 5 20 10 20 30
#30 5 30 10
l1 = [10,20,30]
l2 = [5,10,30]
for value in l1:
for elem in l2:
if value != elem:
print(value, elem, end=’ ‘)
print()


This content originally appeared on DEV Community and was authored by Poornima Ravi

#Problem 1: Print the following Output from the 2 given lists.
#10 5 10 7
#20 5 20 10 20 30
#30 5 30 10 
l1 = [10,20,30]
l2 = [5,10,30]
for value in l1:
    for elem in l2:
        if value != elem:
            print(value, elem, end=' ')
    print()


#Problem 2 : Missing Values

print('===================================================')
l1 = [10,20,30,40,50,70,80,100,120,130,170]
d = l1[1] - l1[0]
i=0
while i<(len(l1)-1):
    if (l1[i+1] - l1[i]) != d :
        print('Missing Value:',l1[i]+d)
    i+=1        


#Problem 3 : l1 = [5,0,10,3,2,7,6,5,4,9,1]
#Find pair of elements with a given sum =10
print('===================================================')
l1 = [5,0,10,3,2,7,6,5,4,9,1]
i=0
j=0
while i <  len(l1):
    while j < len(l1):
        if l1[i]+l1[j] == 10 and j != i:
            print('#Element:',i,'-',l1[i],'#Index[',j,']',l1[j])
        j+=1
    i+=1
    j=0








This content originally appeared on DEV Community and was authored by Poornima Ravi


Print Share Comment Cite Upload Translate Updates
APA

Poornima Ravi | Sciencx (2025-01-06T17:19:16+00:00) Python List Tutorial. Retrieved from https://www.scien.cx/2025/01/06/python-list-tutorial/

MLA
" » Python List Tutorial." Poornima Ravi | Sciencx - Monday January 6, 2025, https://www.scien.cx/2025/01/06/python-list-tutorial/
HARVARD
Poornima Ravi | Sciencx Monday January 6, 2025 » Python List Tutorial., viewed ,<https://www.scien.cx/2025/01/06/python-list-tutorial/>
VANCOUVER
Poornima Ravi | Sciencx - » Python List Tutorial. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/06/python-list-tutorial/
CHICAGO
" » Python List Tutorial." Poornima Ravi | Sciencx - Accessed . https://www.scien.cx/2025/01/06/python-list-tutorial/
IEEE
" » Python List Tutorial." Poornima Ravi | Sciencx [Online]. Available: https://www.scien.cx/2025/01/06/python-list-tutorial/. [Accessed: ]
rf:citation
» Python List Tutorial | Poornima Ravi | Sciencx | https://www.scien.cx/2025/01/06/python-list-tutorial/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.