'Scroll is working with Listbox widget but not working with text widget in tkinter python

I have taken two frames for the Listbox and Text widgets respectively. The scroll is working fine with Listbox but not working with the Text widget. I am using MVS as my IDE. Could anyone explain the reason for the nonfunctioning of the scroll with the Text widget or what is wrong with my code? Thanks

from tkinter import *
from turtle import right
# from tkinter import messagebox

root = Tk()
root.title("GUI Course")
root.geometry("800x500+250+50") 
#root.config(bg="#262626")

#----------------Scroll with Listbox-------------
frame1 = Frame(root, bd=2, relief=RIDGE)
frame1.place(x=100,y=100,height=200,width=200)

scrolly1 = Scrollbar(frame1, orient=VERTICAL)
scrolly1.pack(side=RIGHT, fill=Y)

data = Listbox(frame1, font=("time new roman",20), justify=CENTER, yscrollcommand=scrolly1.set)
data.pack()

scrolly1.config(command=data.yview)

for i in range(0,101):
    data.insert(i, "Data: "+str(i))

#-----------------Scroll with text-----------
frame2 = Frame(root, bd=2, relief=RIDGE)
frame2.place(x=400,y=100,height=200,width=200)

scrolly2 = Scrollbar(frame2, orient=VERTICAL)
scrolly2.pack(side=RIGHT, fill=Y)

text = Text(frame2, font=("times new roman",10), yscrollcommand=scrolly2.set)
text.pack()

scrolly2.config(command=text.yview)

for i in range(0,101):
    flt = 0.0
    text.insert(flt,"Python "+str(i))
    flt += 1


root.mainloop()


Sources

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

Source: Stack Overflow

Solution Source