Reputation: 11
num1 = [1, 3, 5]
num2 = [2, 4, 6]
I have these two lists and need to use a FOR-Loop to organize them so that the print statement prints out the values like this:
1
2
3
4
5
6
I have tried this: for value in num1 and num2:
if num1[0] > num2[0]:
print num1
else:
print num2
Nothing I have tried has worked :( This is my first coding class pls help
Upvotes: 0
Views: 69
Reputation: 41
x=[1,3,5]
y=[2,4,6]
z=x+y
z.sort()
for i in z:
print (i)
output: 1 2 3 4 5 6
Upvotes: 0
Reputation: 71570
Assuming python, use:
for x, y in zip(num1, num2):
print x
print y
Output:
1
2
3
4
5
6
Upvotes: 2
Reputation: 26
let num1=[1, 3, 5],num2 = [2, 4, 6]
let arr=num1.concat(num2).sort((a,b)=>a-b)
for(let i=0;i<arr.length;i++){
console.log(arr[i])
}
Upvotes: 0