Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

if you have a list and the user input one of the keys then output its value

# here is a list of food and its Calories 
list ={
    "Apple": "130",
    "Avocado": "50",
}
# get the key from user and print its value
try:
    item = str(input("Item: "))
    print(list[f"{item}"])
except KeyError:
    pass
Comment

PREVIOUS NEXT
Code Example
Python :: bagging algorithm 
Python :: rich import in python 
Python :: plotting a dendrogram from the distance matrix 
Python :: how to make change the default from python 3.8 to python 3.10.5 on Mint 20 
Python :: graph node structure 
Python :: bold colors in pytohn 
Python :: remove variables withouth variance python 
Python :: critical errors python 
Python :: a Python Numbers 
Python :: restart kernel python 
Python :: add column to wandb.Table 
Python :: django error column last_login cannot be null 
Python :: 1044 uri solution 
Python :: Donut chart graphing funciton 
Python :: filetype: env "DB_PASSWORD" 
Python :: django Account has no customer 
Python :: import mongodatetime flask 
Python :: tkinter centre a button on 1920x1080 
Python :: studygyaan python everywhere - host on heroku 
Python :: numpy get length of list 
Python :: apply numba to itertools import product 
Python :: Python Script to check how many images are broken 
Python :: python exit while loop 
Python :: def f(x) python 
Python :: python numpy find local minima 
Python :: Save this RDD as a SequenceFile of serialized objects 
Python :: 5.4.7 categories python 
Python :: how to create a custom function in python 
Python :: por que usar np.log 
Python :: dargon 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =