PDA

Просмотр полной версии : python list


Basedbounty
04.09.2023, 21:23
Python:






product
=
[
banana
,
orange
,
apple
]
price
=
[
60
,
100
,
80
]
Product_price_zip
=
zip
(
product
,
price
)
Product_price_list
=
list
(
Product_price_zip
)
print
(
Product_price_list
)
Product_price_dict
=
dict
(
Product_price_zip
)
print
(
Product_price_dict
)




выдает ошибку в первой строчке на первое слово в списке, незнаю как решить эту проблему



Exception has occurred: NameError

name 'banana' is not defined

File "C:\Users\use\Desktop\main.py", line 1, in product = [banana, orange, apple] ^^^^^^ NameError: name 'banana' is not defined

kjor32
04.09.2023, 21:24
если я не ошибаюсь строки должны быть так "banana" , "orange" , "apple"

Python:






product
=
[
"banana"
,
"orange"
,
"apple"
]
price
=
[
60
,
100
,
80
]
Product_price_zip
=
zip
(
product
,
price
)
Product_price_list
=
list
(
Product_price_zip
)
print
(
Product_price_list
)
Product_price_dict
=
dict
(
Product_price_zip
)
print
(
Product_price_dict
)

Mamashin
04.09.2023, 21:27
product = [banana, orange, apple]

-

banana

,

orange

,

apple

- являются строками, поэтому их следует поместить в " " или в ' '