Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

unpack too many values in python

record = ('Dave', 'dave@example', '88-55-1212', '84-55-1212')
name, email, *phone = record 

"""
# Use * if you want to unpack N elements from an 
# iterable, but the iterable may be longer than N
# elements, causing a “too many values to unpack” exception.
""" 
Comment

python too many values to unpack

Usually happens with dicts.
hydrogen = {
	"name": "Hydrogen",
	"atomic_weight": 1.008,
	"atomic_number": 1
}

This does not raise an error:
for key, value in hydrogen.items():
	print("Key:", key)
	print("Value:", str(value))

You have to do hydrogen.items() in order to access the keys and values.
Otherwise it will return an error.
Comment

PREVIOUS NEXT
Code Example
Python :: is number python 
Python :: python tuple to list 
Python :: count occurrences of a character in a string python 
Python :: neuronal network exemple python 
Python :: pyspark show all values 
Python :: rnadom number python 
Python :: python convert string to float array 
Python :: pandas groupby apply list 
Python :: # time delay in python script 
Python :: python pop element 
Python :: commentaire python 
Python :: generate list of consecutive numbers 
Python :: load img cv2 
Python :: sort list alphabetically python 
Python :: python push to list 
Python :: how to know the length of a dataset tensorflow 
Python :: pandas strip whitespace 
Python :: how to download instagram profile picture with the help of python 
Python :: how to install python 3.6.0 on debian 
Python :: python plot multiple lines in same figure 
Python :: print class python 
Python :: pd.read_excel 
Python :: python summary() 
Python :: how to install neat 
Python :: element wise subtraction python list 
Python :: python ftplib get list of directories 
Python :: pandas max columns 
Python :: operator precedence in python 
Python :: esp8266 micropython ds18b20 
Python :: shutdown flask server with request 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =