Hello, I'm a student studying Python.
The problem that needs to be solved is, when there are two lists, return the elements in those two lists multiplied by each other.
For example, if a = [1,2], b = [3,4], return 3,4,6,8.
At first, I tried to do fori, jin zip(a,b), and then the elements were circulated one by one, so I could only print three or eight.
I'd really appreciate it if you could tell me how to do it!
python
a = [1,2]
b = [3,4]
x_result = []
for anum in a:
for bnum in b:
x_result.append(anum * bnum)
print(x_result)
© 2024 OneMinuteCode. All rights reserved.