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

  • Home
  • SEARCH
  • 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 7403371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:03:49+00:00 2026-05-29T05:03:49+00:00

I am writing a relatively simple program using Tkinter that is a converter for

  • 0

I am writing a relatively simple program using Tkinter that is a converter for binary, decimal and hex. I am not using any of the Python built in math functions since I figured this was a good way to get some practice with, not only classes and objects, but Tkinter as well.

I have a method that checks to make sure a binary string is valid by checking if it contains any of the digits 2-9, which would make it invalid.

To do this I am using an if statement embedded within a for loop

bits = '011101'    #self.input_str.get()
bit_list = [i for i in bits]
ill_bits = ['2', '3', '4', '5', '6', '7', '8', '9']

for bit in bit_list:

    if bit in ill_bits:  
        print('yes')
        #self.output_disp.delete(0.0, END)
        #self.output_disp.insert(0.0, "That bit string is invalid")
    else:
        print('no')
        #self.from_binary(self.dec_bttn, self.hex_bttn)`

The two print() functions are actually not part of the program, they are there as I keep testing different things. The commented out parts are the code that I want to run in the test area of the Tkinter app as results of the validity test.

What is happening here is that the

self.output_disp.delete(0.0, END)
self.output_disp.insert(0.0, "That bit string is invalid")

is only run if the very last bit in the test is found in both lists. For example a bit string of: 111019 will have That bit string is invalid shown in the text area, but 111911 will not. Although both bit strings will print yes in the console when the 9 is iterated through, only the one with the 9 in the last spot will run the two lines of code that start self.output_disp….

  • 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-05-29T05:03:50+00:00Added an answer on May 29, 2026 at 5:03 am

    Your flow is a little off. You need to break after the first failure, and have the else block associated with the for instead of the if.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively simple program that currently uses 1 thread (main). The application
I am writing a relatively small and simple Windows Service, and using Moles to
I'm writing a simple graphics engine that draws textures on the screen using OpenGL
I am writing a C# Project that is relatively simple. Think Public Web Terminal.
Is there a relatively simple way in nant, without writing a custom task, to
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I'm writing a Python module that wraps out a certain web service API. It's
I'm writing a relatively simple proxy app for a web service. The general idea
I'm working on a relatively simple iPhone application that has a multi-round Timer with
I am writing a program that has to strip pretty long strings of quite

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.