Avatar of Swaminathan K
Swaminathan KFlag for India

asked on 

unable to Convert tuple or list into dictionary in python

Hi Team,

Iam getting the below error while iam creating thedictionary object , any help is really appreciated

Case 1 : Trying to create a tuple and using the tuple trying to create a dictionary
>>> t=(1,2),
>>> d=dict(t)
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    d=dict(t)
TypeError: cannot convert dictionary update sequence element #0 to a sequence

Case 2: Trying to create a list and using the list creating a dictionary
>>> l=[1,2,3,4]
>>> d=dict(l)
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    d=dict(l)
TypeError: cannot convert dictionary update sequence element #0 to a sequence
Python

Avatar of undefined
Last Comment
Swaminathan K
ASKER CERTIFIED SOLUTION
Avatar of Louis LIETAER
Louis LIETAER
Flag of France image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Swaminathan K

ASKER

awesome
Python
Python

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

6K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo