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 :: pandas concat series into dataframe 
Python :: remove 0 values from dataframe 
Python :: matplotlib multiple plots with different size 
Python :: Insert numpy array to column 
Python :: load all csv files in a folder python pandas 
Python :: remove stopwords from list of strings python 
Python :: how to get started with python 
Python :: python create tuple from input 
Python :: print all values of dictionary 
Python :: python run exe with arguments 
Python :: python nameerror input 
Python :: how to stop code in ursina 
Python :: pandas series to list 
Python :: df order by 
Python :: pandas select row by index 
Python :: alarm clock python 
Python :: remove rows or columns with NaN value 
Python :: schedule task to midnight python 
Python :: robot append to list with for loop 
Python :: pandas sort values by multiple columns 
Python :: pyhton find dates in weeks 
Python :: utc to local time python 
Python :: Python program to check leap year or not? 
Python :: opencv face detection code python webcam 
Python :: latest django version 
Python :: installing more modules in pypy 
Python :: suppress warning jupyter notebook 
Python :: discord.py on command error 
Python :: py pause script 
Python :: insert video in tkinter 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =