问题
I am using jupyte notebook
This is the Code
from ipywidgets import interact
define a function to work with (cubes the number)
def myfunction(arg): return arg+1 interact(myfunction, arg=9);
The result showing is 10 instead it should be showing a slider
Showing: enter image description here
Instead it show: enter image description here
回答1:
I can't tell exactly what went wrong with what you did because there are formatting issues with your post -- you need to indent the code 4 spaces when you ask the question to make it look right, which effects the meaning because Python is sensitive to white space.
I modified your text and got it to work for me
from ipywidgets import interact
def myfunction(arg):
return arg+1
interact(myfunction, arg=9)
Screenshot:
来源:https://stackoverflow.com/questions/53516965/jupyter-interactive-widget-not-executing-properly