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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:10:00+00:00 2026-06-12T03:10:00+00:00

Problem: I have a string of numbers, lets call it strNumbers. I need to

  • 0

Problem:

I have a string of numbers, lets call it strNumbers. I need to go through this string, character by character doing calculations on each number up until a certain point. At that point, I need to start pulling two of the numbers at a time and doing calculations on those two numbers. Here’s what I have come up with thus far, as you can see I have figured out how to iterate through the loop pulling single characters no problem. I also understand that I need a counter to determine exactly when I need to start pulling two characters at a time, but now what? Any help is appreciated, thank you.

for i in strNumbers:    
    intNumber = int (i)
    **do math on intNumber*
    **print result**
    count = count +1
    if count == 5:
        ??

Edit:
I’ve decided to use two separate loops to accomplish this task, I’ve encountered another issue however. The following code throws a, TypeError: Can’t convert ‘int’ object to str implicitly at line, number = int(strTail[i:i+2])

for i in strTail:
    number = int(strTail[i:i+2])
    intRooted = int( math.sqrt(number))
    strDecoded += str(intRooted)

Logically this seems like exactly what I want to do, I put to pull the number at position ‘i’ and the number one position ahead of i. What am I missing here?

  • 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-12T03:10:02+00:00Added an answer on June 12, 2026 at 3:10 am

    You can treat the string as an array accessing each character individually (or two at a time). So once you reach your designated amount you can set a flag that will tell your loop to start taking two characters at a time.

    i=0
    offset = 1
    while i <len(str_numbers):
        if offset>1:
            int_number = int(str_numbers[i:i+offset])
        else:
            int_number = int(str_numbers[i])
        if i==5:
            offset=2
        i+=offset
    

    EDIT:
    I just thought of a less confusing way of doing this:

    offset=1
    i=0
    while i<len(str_numbers):
        if i==5:
            offset=2
        int_number = int(str_numbers[i:i+offset])
        i+=offset
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have a string that looks like this: [1=>2,3,4][5=>6,7,8][9=>10,11,12][13=>14,15][16=>17,18] Question: How can you
Lets say I have table like this: String | Int1 | Int2 "foo" 5
it's better to call this problem as puzzle. Problem is I allocating a number
i have a problem. i want to get info about my string have other
I have a problem with the replace method of javascript. I have a string
simple problem with a simple question. I have a string, in C# i can
My problem is, when I want to convert (result[i].JobOrder) to int.I have a string
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
I have a problem with sending string via game center. I am able to
I have a problem that output string must be utf8-formatted, I am writing currently

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.