I am planning to return the value of gameMode because I would like to use the output of gameMode being easy medium or hard for a game I am doing but there is always a name error. Is there any way to solve this? picture of the error: enter image description here
from ipywidgets import Button, HBox
Modes = ['Easy', 'Medium','Hard']
switch = [Button(description=name) for name in Modes]
combined = HBox([items for items in switch])
def upon_clicked(btn):
gameMode=btn.description.lower()
for n in range(len(Modes)):
switch[n].style.button_color = 'gray'
btn.style.button_color = 'pink'
for n in range(len(Modes)):
switch[n].on_click(upon_clicked)
display(combined)
gameMode