Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:30:28+00:00 2026-06-01T14:30:28+00:00

So, I starting to learning Tkinter in Python, (just starting to learn Python, for

  • 0

So, I starting to learning Tkinter in Python, (just starting to learn Python, for that matter) and decided to try and create a factorial calculator using Tkinter. I’m not going for anything too fancy and here is what I’ve come up with:

from Tkinter import *
import tkMessageBox

def calculate():
    number = inputNumber.get()
    inputNumber.delete(0, END)
    product = 1
    for i in range(number):
        product = product * (i+1)
    inputNumber.insert(product)

cal = Tk()
cal.title("Factorial Calculator")
cal.geometry('450x300+200+200')

factorialNumber = IntVar()
inputNumber = Entry(cal, textvariable=factorialNumber)
inputNumber.pack()

enterButton= Button(cal, text="CALCULATE!", width=20,command=calculate)
enterButton.pack(side='bottom',padx=15,pady=15)

cal.mainloop()

So I ran this, and when I hit the “CALCULATE!” button, it spits out this error:

Traceback (most recent call last):
File "C:\Python27\Lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Users\Wesley Yu\Desktop\New folder (4)\module1.py", line 8, in calculate
for i in range(number):
TypeError: range() integer end argument expected, got str.

I’ve already tried fixing it, but to no avail. What should I do?

Sorry if this is very basic, still learning 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:30:30+00:00Added an answer on June 1, 2026 at 2:30 pm

    Entries result in strings. Pass it to the int() constructor first.

    >>> int('42')
    42
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out in learning Ruby and I've written a program that generates
I'm just starting out learning javascript, and tried to write a little script that
I am just starting my journey into learning databases/SQL and the like. I decided
just considering starting to learning python but I have one concern before I invest
Just starting learning about ajax requests using jQuery. I've tried looking at other posts
I'm just starting out learning python (for webapp usage) but I'm confused as to
I've just starting learning jQuery and AJAX. I'm able to load a local page
I'm just starting out learning OpenCL. I'm trying to get a feel for what
I have been learning python for some time now. While starting this learning python
I am starting with google maps. just learning. while ago, it was working. now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.