user input dictionary python

for i in range(3):
    data = input().split(' ')
    d[data[0]] = int(data[1])

0
8
Awgiedawgie 440220 points

                                    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)) 

0
0
3.7
10
Awgiedawgie 440220 points

                                    >>> fruits = {}
>>> key1 = input("Enter first key for fruits:")
Enter first key for fruits:a
>>> value1 = input("Enter first value for fruits:")
Enter first value for fruits:apple
>>> key2 = input("Enter second key for fruits:")
Enter second key for fruits:b
>>> value2 = input("Enter second value for fruits:")
Enter second value for fruits:banana
>>> fruits[key1] = value1
>>> fruits
{'a': 'apple'}
>>> fruits[key2] = value2
>>> fruits
{'a': 'apple', 'b': 'banana'}
>>># Same variable names for keys and values can be used if used inside a loop like this
>>> fruits.clear()
>>> fruits
{}
>>> for i in range(2):
	key = input("Enter key for fruits:")
	value = input("Enter value for fruits:")
	fruits[key] = value
    
Enter key for fruits:a
Enter value for fruits:apple
Enter key for fruits:b
Enter value for fruits:banana
>>> fruits
{'a': 'apple', 'b': 'banana'}

3.7 (10 Votes)
0
0
3
Awgiedawgie 440220 points

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

0
0
3.8
10
Egis 630 points

                                    # 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]  

3.8 (10 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
take input in dictionary python take dict input in python how to take input dictionary in python python program to create a dictionary from user input how take dictionary as input in python input dictionary in python 3 key value input in python dictionary python dictionary from input user inputted dictionary python function to input as dictionary in python input a dictionary from user in python how to take input in python dictionary how to get dictionary input from user in python store user input in dictionary python python dictionary input take key input in dictionary python how to take input from user as dictionary input dictionary how to use python dictionary and take information based on user input how to input into a dictionary python how to get input in dictionary in python dictionary in python input python input in dictionary how to get input from a user in python dictionary input dictionary in function python create dictionary values from user input python create dictionary values python from user input how to take input from user in dictionary how to create dictionary in python by user input take input and create dictionary in python input dictonary in python create dictionary of dict in python by user input How to use dictionary with user input in Python take input from user in dictionary python how to store user input in dictionary python user input in python dic user input to a dictionary python user_input to a dictionary python how to take input as dictionaryin python how to input information in python dictionary user input in dictionary in python3 user input data dictionary python input as key dictionary python how to take input values dictionary in python python how to use input with dictionary python dictionary take input from user take user input in python dictionary input in dictonaries get dictionary input in python take input for dictionary in python create dictionary python from user input how to take input in dictionary in python as key dictionary call based on user input python how to take a string and user input for a dictionary key in python how to access dictionary key based on user input python taking dictionary input in python create dictionary from input in python how to input dictionary in python from user how to input dictionary how to take dict input in python can you do inputs in dictionary python python take dictionary input python inputs into a dictionary load input to dictionary python input in a dictionary python python funciton input to dict dictionary python taking inputs dictionary function input python how a dictionary as a user input in python taking input in python dictionary taking input in dictionary in python dictionary user input in python take input in dictionary in python input dict in python dictionary as input python Accessing Elements from Python Dictionary by user input how to read from a dictionary in python with user input user input dictionary how to get user input for dictionary in python python enter input as dictionary values python enter output as dictionary vlaues add input to dictionary python python taking input in a dictonary input data into a dictionary and print the dictionary in python write a program to create dictionary using input in python getting dictionary input take input and store it in a dictonary python how to creat a diction with input create dictionary with input python python dictionary input from user dictionary value - user input python python dictionary show keys and values with input init key value dictionnary how to get dictionary input dictionary input from user in python3 input into dictionary python input values in dictionaries input new value to dictionary python how to add input value in dictionary python how to give input of key in dictionary python how to input to a dictionary python creating and input dictionary Explain what output = {**input} does in python where input is a dict. number dictionary with input python how to create a dictionary bu adding inputs in python check dictionary empty how to input key and values to empty dictionary in python how to input a dictionary in python input key and value in dictionary python python input code for dictionary create dict from input python input dictionary in python get value in dictionary with input python how to take user input in dictionary in python create dictionary from user input python how to print various user input in key value pair of dictionary how to use input function in python to print the value in dictionary dictinary with user input how to add user input to a dictionary with different keys print user input in dictionary multiple times python dictionary search multiple parameters with user input creat a dictinary by using user input in dictionary python how to take user input input values in dictionary python how to take dictionary input in python how to turn an input to a dictionary how to turn an input to a dictionarry how to make a dictionary with mulitple inputs how to take input and make a dictionary python how to take input and make a dictionary dictionary in python user input create dictionary from input python how to create a dictionary from user input in python python input a dictionary how to add input value to a dictionary in python enter keys and values in dictionary python how to take input from user in dictionary in python input a dictonary python making a dictionary from user inout in python python input strin keyname and get value dict generate new dict from input python python dictionary input value can a dictionary have 3 inputs?? how to make dictionaries in python from inputs taking input in dictionary python how to make input as dict key how to take input as dictionary in python how to input dictionary in python assign inputs to dictionary how to make dictionary inputs values in python how to make user enter the values to get keys in dictionary python how to turn input into a dictionary python input data into dictionary python enter data in dictionery in python user input key value dictionary in python user input in dictionary in python how to take multiple inputs of key and value of dictionary in python python enter key value dictionary user input to dictionary python user input using dictionary in python python input() to diction create a dictionary from input python how to take input in dictionary python how to input values to a function to create dictionary python how to create a dictionary with user input in python and order the data using dictionaries with input in python how to input data in dictionary in python how to create a dictionary in python with user input user input python dictionary dictionary key input input values using in python dictionary how to make input dictionary into dictionary python enter values in dictionary python input dict pyhton dictionary python more than one value as inp take dictionary as input python user input dict python how to give multiple inputsin python dictionary pass multiple inputs to python dictionary with or condition take input as dictionary in python how to set dictionary to input values how to take input in dictionary in python 3 dict input data python how to take a dictionary as input in python taking dic as input in python how to get dictionary input in python how to take user input for dictionary in python taking input as dictionary in python code for input dict python input a dictionary in python take input in dict in python how to update a dictionary in python through user input get value for a input variable in dictionary python ask user to enter dictionary in python how to take dictionary as input in python python program to create a dictionary user gives input dictionary input from user in python how to take input of dictionary in python input value in dictionary python dictionary python input how to input in dictionary in python inputing in python dictionary input dictionary python 3 dictionary input python how to add keys and values in dictionary from user input python how to add keys and values in dictionary from user input function set values in dictionary while taking input python entering values in an empty dictionary in python user input dictionary in python input in dictionary python convert inputs into dictionary python make a dictionary form input values Python input to dictionary python many keys ont value python how to enter values in dictionary in python dictionary user input python how to inter key and value dictionaty python user defined input in dictio how to input user defined value in dictionary in python how to input values in dictionary python get input from user and store as dictionary in python python user input dictionary python input dictionary how to input multiple keys in dictionary python how to accept values and make a dictionary in python how to input elements in dictionary in python taking input a python dictionary how to take input in a dictionary when the key and value how to take input in dixtionary how to take multiple input in dictionary in python take inout from python in codechef how to take input in dictionary in python input dictionary python user input dictionary python python program to make input into a dictionary python create dictionary from input python take dictionary as input how to take dictionary as input from user in python dictionary input in python how to get input for dictionary in python how to make user input dictionary python how to take input for dictionary in python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source