Q:

trying to pass the current radiobutton value in tkinter but getting global name not defined

I have a list of radiobuttons and linked to the same variable and I have a submit button that when clicked I want it to pass the current variable value to another function which will then use that number. I used lambda function but when the function should be called I get global name 'num' is not defined. num is my function. Below is my code. Thank you very much. 
from tkinter import *
import random

class App:

def __init__(self, master):

def say_one(self):

    v = IntVar()
    window = Toplevel(root)

    for i in range(1,11):
        self.label = Radiobutton(
            window, text = i , fg = "red", 
            value = i, variable = v
        ).grid(row =i, column =0)

    # error is occurring in the next line
    self.report = Button(
        window, text="submit", command= lambda : num (v) 
    ).grid(row = 12, column = 0)        

def num( number):
    print(number)

root = Tk()

app = App(root)

root.mainloop()

A:

Indent your code correctly.
from tkinter import *
import random

class App:
    def __init__(self, master):
        self.say_one()

    def say_one(self):
        v = IntVar()
        window = Toplevel(root)

        for i in range(1,11):
            self.label = Radiobutton(
                window, text = i , fg = "red", 
                value = i, variable = v
            ).grid(row =i, column =0)

        # error is occurring in the next line
        self.report = Button(
            window, text="submit", command=lambda: num(v) 
        ).grid(row = 12, column = 0)        

def num(var):
    print(var.get())

root = Tk()
app = App(root)
root.mainloop()

I fixed the indentation, changed the num function to print variable's value instead of printing variable itself.

