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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:08:10+00:00 2026-06-03T13:08:10+00:00

Before I start let me just say that I’m really new to programming so

  • 0

Before I start let me just say that I’m really new to programming so please don’t kill me.

As an exercise I wrote a script that is supposed to take a list of hex numbers from a txt, convert them to decimal and write them to another file. This is what I came up with:

hexdata = open(raw_input("Sourcefile:")).read().split(',')
dec_data = []

print hexdata
x = -1
for i in hexdata:
    next_one = hexdata.pop(x+1)
    decimal = int(next_one, 16)
    print "Converting: ", next_one, "Converted:", decimal
    dec_data.append(decimal)

print dec_data

target = open(raw_input("Targetfile: "), 'w')
for n in dec_data:
    output = str(n)
    target.write(output)
    target.write(",")

When I run the script it finishes whithout errors however it only converts and writes the first 30 numbers from my sourcefile and ignores all the other ones, even though they are loaded into the ‘hexdata’ list. I’ve tried several variations but it never works with all the numbers (48). What am I doing wrong?

  • 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-03T13:08:12+00:00Added an answer on June 3, 2026 at 1:08 pm

    Your first loop is trying to iterate over hexdata, while at the same time pulling values out of the list using hexdata.pop(). Just change it to something like:

    for next_one in hexdata:
        decimal = int(next_one, 16)
        print "Converting: ", next_one, "Converted:", decimal
        dec_data.append(decimal)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I start let me say I am new to RavenDB. I am just
Before I start with the real question, let me just say that I might
Before I start, let me say that I looked at all the similar questions
Let me start by saying that this app was working fine the day before.
Let's say I'd like to start a small linux distro before my ordinary operating
Let me start off by saying that I am very new to WPF and
Let me just say up front that what I'm aware that what I'm about
Before start let me tell my experience: I am experienced with C#.NET, web services,
Before you start laughing at such a simple question let me explain: I am
Ok here is my problem : Before i start the description, let me to

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.