'Tkinter Options menu not displaying Selected value in option menu in Python

Tkinter Options Menu not displaying selection receiving below error

AttributeError: 'NoneType' object has no attribute 'set'

Used this code to add dynamic list to the option menu. Option menu changing dynamically when new list is generated but when select the item from the list the above error is coming

dropdownmenu=StringVar()
om=dropdownmenu.set("Select any section")
lst=final_key_list
drop_menu=drop.children['menu']
for val in lst:
   drop_menu.add_command(label=val,command=lambda v=om,l=val:v.set(1))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source