Answered

Python - Merge Two Lists Into a Dictionary

Which is the best way of merging the list 1, 2 or 3 ?

```
keys_list = ['A', 'B', 'C']
values_list = ['blue', 'red', 'bold']
#There are 3 ways to convert these two lists into a dictionary
#1- Using Python's zip, dict functionz
dict_method_1 = dict(zip(keys_list, values_list))
#2- Using the zip function with dictionary comprehensions
dict_method_2 = {key:value for key, value in zip(keys_list, values_list)}
#3- Using the zip function with a loop
items_tuples = zip(keys_list, values_list)
dict_method_3 = {}
for key, value in items_tuples:
if key in dict_method_3:
pass # To avoid repeating keys.
else:
dict_method_3[key] = value
```

I was wondering why this isn't working $\sqrt{2/8} \ne 22 $

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$

and they are

$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}$$

**953**Views

**7**Answers

10 months ago

14 days ago

Tags