user input dictionary python

Solutions on MaxInterview for user input dictionary python by the best coders in the world

showing results for - "user input dictionary python"
Jonas
11 Oct 2020
1# Creates key, value for dict based on user input
2# Combine with loops to avoid manual repetition
3class_list = dict() 
4data = input('Enter name & score separated by ":" '5temp = data.split(':') class_list[temp[0]] = int(temp[1])  
6
7OR
8
9key = input("Enter key") 
10value = input("Enter value") 
11class_list[key] = [value]  
Federica
20 Oct 2019
1>>> fruits = {}
2>>> key1 = input("Enter first key for fruits:")
3Enter first key for fruits:a
4>>> value1 = input("Enter first value for fruits:")
5Enter first value for fruits:apple
6>>> key2 = input("Enter second key for fruits:")
7Enter second key for fruits:b
8>>> value2 = input("Enter second value for fruits:")
9Enter second value for fruits:banana
10>>> fruits[key1] = value1
11>>> fruits
12{'a': 'apple'}
13>>> fruits[key2] = value2
14>>> fruits
15{'a': 'apple', 'b': 'banana'}
16>>># Same variable names for keys and values can be used if used inside a loop like this
17>>> fruits.clear()
18>>> fruits
19{}
20>>> for i in range(2):
21	key = input("Enter key for fruits:")
22	value = input("Enter value for fruits:")
23	fruits[key] = value
24    
25Enter key for fruits:a
26Enter value for fruits:apple
27Enter key for fruits:b
28Enter value for fruits:banana
29>>> fruits
30{'a': 'apple', 'b': 'banana'}
Sarah
08 May 2020
1class_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)) 
Ivanna
04 May 2017
1d=dict(input().split() for x in range(n))
2print(d)
queries leading to this page
how to take input in python dictionaryuser inputted dictionary pythontake input in dictionary in pythoncreating and input dictionaryhow to take input in dictionary in python as keydictionaries in python with inputinput for dictionary in pythontake input for dictionary in pythoncreate dictionary values python from user inputinput data into dictionary pythoninput into dictionary pythonhow to use python dictionary and take information based on user inputhow to take input in dictionary in pythoninput a dictionary in pythonpython input in dictionarypython enter input as dictionary valueshow to take input of dictionary in pythoninput a dict in pythonhow to take input values dictionary in pythonhow to take a dictionary as input in pythonhow to get input dictionaryhow to get input from a user in python dictionaryinput dictionaryhow to create a dictionary in python with user inputadd input to dictionary pythonwrite a program to create dictionary using input in pythondictionary python inputhow to take input from user as dictionarypython method with dictionary inputhow to creat a diction with inputhow to give input of key in dictionary pythontake input and store it in a dictonary python input dictionary pythondictionary call based on user input pythonhow to take input dictionary in pythonpython function input dictionarypython dictionary from inputinput in dictonariestake input as dictionary in pythoninput in dictionary pythonpython take dictionary inputhow to take input from user in dictionaryget dictionary input in pythonhow to get input in dictionary in pythonhow to input key and values to empty dictionary in pythondictionary user input in pythonkey value input in python dictionarypython key inputdictionary in python inputinput data into a dictionary and print the dictionary in pythoninput dictionary in pythoninput a dictionary from user in pythoncreate dictionary python from user inputhow to take dictionary input in pythontake dictionary as input pythonpython dictionary with inputhow to input information in python dictionarytake dict input in pythoncreate a dictionary that take input from user in pythonhow to create a user input dictionary in pythonuser input in dictionary in python3how to take dictionary as input in python functiontake user input dictionary in pythonaccessing elements from python dictionary by user inputtaking input in dictionary in pythonpython dictionary show keys and values with inputpython input dictionarydictionary input pythonhow to use dictionary with user input in pythonpython user input dictionarypython input a dictionaryinput to dictionary pythonuser input to a dictionary pythonhow to store user input in dictionary pythonhow to input in dictionary in pythondictionary input from user in python3how to add input value in dictionary pythonhow to take input as dictionary in pythontake user input in python dictionaryhow to create a dictionary bu adding inputs in pythonhow to access dictionary key based on user input pythoninput new value to dictionary pythonhow to input to a dictionary pythoninput dictionary from user pythontaking input in python dictionaryuser input into dictionary pythoncreate dictionary of dict in python by user inputpython taking input in a dictonarypython dict inputinput dictionary in python 3user input to a dictionary pythonhow to take user input in dictionary in pythonexplain what output 3d 7b 2a 2ainput 7d does in python where input is a dict how to take input from user in dictionary in pythontake key input in dictionary pythoninput dictonary in pythonpython dictionary methods and user inputhow do you input a dictionary in python 3fdictionary in python taking inputdictionary input from useruser input dictionary in pythonhow to input a dictionary in pythonuser input data dictionary pythoninput as key dictionary pythonhow to take dictionary input from user in pythondictionary input from user in pythonhow to input into a dictionary pythonhow to get input for dictionary in pythonhow to get dictionary input from user in pythoninput values in dictionariesuser input in python diccreate dictionary with input pythonhow to read from a dictionary in python with user inputhow to take dictionary as input in pythonpython dictionary take input from userhow to input dictionary in pythonhow to input dictionary in python from userhow a dictionary as a user input in pythoninput in dictionary in pythontake dictionary as user inputuser input dictionaryhow to take dict input in pythonpython dictionary input valuepython enter output as dictionary vlauestaking dictionary input in pythontake input in dictionary pythonuser input in dictionary in pythondictionary input in pythonnumber dictionary with input pythoncreate dictionary and take input from user in pythoncheck dictionary emptyhow to take user input for dictionary in pythoncreate a dictionary that take input pythonhow take dictionary as input in pythoncreate dictionary values from user input pythonuser input dictionary pythondictionary user input pythonhow to take input for dictionary in pythonhow to get dictionary inputhow to take input as dictionaryin pythoninit key value dictionnaryhow to create dictionary in python by user inputpython dictionary inputtake input from user in dictionary pythonstore user input in dictionary pythonuser input dictionary python