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

PREVIOUS NEXT
Code Example
Python :: how to use function in python 
Python :: python - count total numeber of row in a dataframe 
Python :: how to count null values in pandas and return as percentage 
Python :: print(hello world) 
Python :: custom jupyter notebook 
Python :: pandas save dataframe to csv in python 
Python :: django queryset group by 
Python :: random 0 or 1 python 
Python :: how to use fastapi ApiClient with pytest 
Python :: python - find specific name in a df 
Python :: drop all unnamed columns pandas 
Python :: remove new line character from string python 
Python :: test_size 
Python :: python turtle spiral 
Python :: creating empty set and append python 
Python :: python optional arguments 
Python :: python to mac executable 
Python :: flask decoding base 64 image 
Python :: button tkinter 
Python :: find min and max from dataframe column 
Python :: convert 2d string array to float python 
Python :: python json web request 
Python :: seaborn pink green color palette python 
Python :: print python float precision 
Python :: python turtle jupyter notebook 
Python :: use python dotenv 
Python :: heroku django procfile 
Python :: get every item but the last item of python list 
Python :: get column index of maximum value in each row pandas 
Python :: append object python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =