Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

user input dictionary python

# Creates key, value for dict based on user input
# Combine with loops to avoid manual repetition
class_list = dict() 
data = input('Enter name & score separated by ":" ') 
temp = data.split(':') class_list[temp[0]] = int(temp[1])  

OR

key = input("Enter key") 
value = input("Enter value") 
class_list[key] = [value]  
Comment

how to get dictionary input from user in python

family = {}
num = int(input("How many elements?: "))
for i in range(num):
    k = input("Enter key: ")
    v = input("Enter value: ")
    family.update({k:v})
print(family)
Comment

how to get dictionary input from user in python

family = {}
family["Name"] = input("Enter name: ")
family["Age"] = int(input("Enter age: ")) 
family["Relation"] = input("Enter relation: ")
print(family)
Comment

dictionary input from user in python3

d=dict(input().split() for x in range(n))
print(d)
Comment

python dictionary input

class_list = dict() data = input('Enter name & score separated by ":" ') temp = data.split(':') class_list[temp[0]] = int(temp[1])  # Displaying the dictionary for key, value in class_list.items(): 	print('Name: {}, Score: {}'.format(key, value)) 
Comment

PREVIOUS NEXT
Code Example
Python :: how to check if all values in list are equal python 
Python :: print specific key in dictionary python 
Python :: pandas print groupby 
Python :: check if variable is none 
Python :: pandas heading 
Python :: python local nosql database 
Python :: how to run python code in python 
Python :: Use len with list 
Python :: get time and dates string 
Python :: app.py 
Python :: check boolean python 
Python :: division of 2 numbers in python 
Python :: smooth interpolation python 
Python :: Redirect the Python Script Output to File 
Python :: unicodedata no accent 
Python :: get_queryset django rest framework 
Python :: python remove all occurrence of an items from list 
Python :: __str__ returned non-string (type User) 
Python :: dataframe select row by index value 
Python :: how to find greatest number in python 
Python :: are logN and (lognN) same 
Python :: strip plot 
Python :: python all() function 
Python :: python any() function 
Python :: python write float with 2 decimals 
Python :: class method in python 
Python :: python look for image on screen 
Python :: stack python 
Python :: describe in python 
Python :: class inheritance 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =