Python Forum
#python .... Need to develop a if condition from two lists - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: #python .... Need to develop a if condition from two lists (/thread-13223.html)



#python .... Need to develop a if condition from two lists - ginu - Oct-04-2018

I need to solve a problem could anyone help me with the same. Below is the detailed description of my problem
I have two list , lets says
list1=['a1','b1','c1']  
list2 = ['a2','b2,'c2']
I
I need to develop a if condition using these two list with 'and' and 'or' condition just like below :
if((data1 =='a1' and data2=='a2') or (data1 == 'b1' and data2=='b2') or (data1 =='c1' and data2=='c2')):
 print("success")
else:
 print("failed")
Could you help me with how to form the same without hardcoding the values


RE: #python .... Need to develop a if condition from two lists - ichabod801 - Oct-04-2018

What have you tried? We are not big on writing code for people here, especially not in the Homework section. But we are big on helping people fix code that isn't working.


RE: #python .... Need to develop a if condition from two lists - gruntfutuk - Oct-05-2018

You might want to look at the zip() function.