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 :: all python 
Python :: dataset to list python 
Python :: post to get 
Python :: how to combine sets using update() Function 
Python :: how to check if a function is callable in puyjom 
Python :: Adding a new nested object in the list using a Deep copy in Python 
Python :: How to subtract all the numbers in a list from the first number? 
Python :: how list ul info with python 
Python :: how to get the string between brackets in a string in python 
Python :: python denest list of anything 
Python :: is c++ easier than python 
Python :: ssd 1306 esp32 python 
Python :: operator overloading in python 
Python :: Create New Entry Into Table Django 
Python :: Lightbank b2c 
Python :: welcoming users using discord.py 
Python :: linear plot 1D vector for x python 
Python :: Python - Common Conditional Statements 
Python :: python Access both key and value using iteritems() 
Python :: django create view template 
Python :: blue ray size 
Python :: check two list python not match 
Python :: a guide to numpy and pandas 
Python :: python initialize a 2d array 
Python :: odoo wizard current user login 
Python :: removing an item from a list and adding it to another list python 
Python :: Only show legend of inner donut 
Python :: python for schleife 
Python :: Python Pipelining Generators 
Python :: Python DateTime Time Class syntax 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =