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 7487899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:41:06+00:00 2026-05-29T14:41:06+00:00

The specific line is b = int(a.translate(None, \t<,)) a is a string which contains

  • 0

The specific line is

b = int(a.translate(None, "\t<,"))

a is a string which contains "\t<56,000". When I print the result of the translate operation I get “56000”, but when it gets to the int() line, it gives me an error saying

ValueError: invalid literal for int() with base 10: ''

as if the string I gave it was null for some reason. Is there something I’m doing wrong? (also I’m reading the string in from a txt file if that changes anything)

Here is the source code: link

  • 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-29T14:41:07+00:00Added an answer on May 29, 2026 at 2:41 pm

    The problem is that in addition to all the strings you think you are getting, you also end up with a few strings consisting only of “\t”, which is then turned into empty strings by the string conversions.

    Adding an additional clause to the if-test when testing for empty strings solves this:

    if (i != " ") and (i != "") and (i != "\t"):
        (...)
    

    instead of:

    if i != " " and i != "":
        (...)
    

    Also, consider using parenthesis for clarity…

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

Sidebar

Related Questions

Is it possible to extract the string content of a specific line in a
Here is the situation public class A { public string Prop1 {get;set;} public int
I get a NullPointerException at a line on which just a simple null check
I'm trying to read a specific line from a file and I can get
I can go to a specific line number by double clicking in the status
I want to force the current execution line to a specific line in the
What is the best way to overwrite a specific line in a file? I
How would I scan a directory for a specific line of text and list
XP-specific answers preferred, but others are welcome too.
Ok, my program in this specific section takes a line of data from a

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.