# How to get selected value from listbox in tkinter in Python # Python3 program to get selected# value(s) from tkinter listbox# Import tkinterfrom tkinter import *# Create the root windowroot = Tk()root.geometry('180x200')# Create a listboxlistbox = Listbox(root, width=40, height=10, selectmode=MULTIPLE)# Inserting the listbox itemslistbox.insert(1, "Data Structure")listbox.insert(2, "Algorithm")listbox.insert(3, "Data Science")listbox.insert(4, "Machine Learning")listbox.insert(5, "Blockchain")# Function for printing the# selected listbox value(s)def selected_item():         # Traverse the tuple returned by    # curselection method and print    # corresponding value(s) in the listbox    for i in listbox.curselection():        print(listbox.get(i))# Create a button widget and# map the command parameter to# selected_item functionbtn = Button(root, text='Print Selected', command=selected_item)# Placing the button and listboxbtn.pack(side='bottom')listbox.pack()root.mainloop()