I have a two variable, a = ("0", "2", "0") b = ("Jenny", "Christy", "Monica") if I run the code
x = min(zip(a, b)) print(x) my output will be ('0', 'Jenny')
If I want the output- (('0', 'Jenny'),('0','Monica))- what should I do?
I have a two variable, a = ("0", "2", "0") b = ("Jenny", "Christy", "Monica") if I run the code
x = min(zip(a, b)) print(x) my output will be ('0', 'Jenny')
If I want the output- (('0', 'Jenny'),('0','Monica))- what should I do?
a = ("0", "2", "0") b = ("Jenny", "Christy", "Monica") x = list(zip(a, b)) output = [] for i in range(len(x)): if min(a) in x[i]: output.append(x[i]) print(output) Actually when your code finds two minimum values in a, then it compares the minimum value of b also and it finds 'Jenny' first letter J is smaller than 'Monica' first letter 'M'. Thats why it returns only one value
a = ("0", "2", "0") b = ("Jenny", "Christy", "Monica") x = () for i in range(len(a)): if a[i] == "0": x += (a[i],b[i]) print(x) #Brute force way.