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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:28:04+00:00 2026-06-07T13:28:04+00:00

I am in the process of writing a search engine for the experience and

  • 0

I am in the process of writing a search engine for the experience and the knowledge. Right now, I am in the process of building a crawler and its accompanying utilities. One of these is the URL normalizer. This is what I am trying to build right now, and more specifically I am stuck at the point where I have to make a method to take a url, and capitalize letters that follow a ‘%’ sign. My code so far:

def escape_sequence_capitalization(url):
        ''' The method that capitalizes letters in escape sequences.
        All letters within a percent - encoding triplet (e.g. '%2C') are case
        insensitive and should be capitalized.

        '''
    next_encounter = None
    url_list = []
    while True:
        next_encounter = url.find('%')
        if next_encounter == -1:
            break

        for letter in url[:next_encounter]:
            url_list.append(letter)

        new_character = url[next_encounter + 1].upper()
        url_list.append(new_character)
        url = url[next_encounter:]

    for letter in url:
        url_list.append(letter)

    return ''.join(url_list)

Can someone please guide me to where my error is? I would be grateful. Thank you.

EDIT: this is what I am trying to achieve:

http://www.example.com/a%c2%b1b → http://www.example.com/a%C2%B1b
  • 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-07T13:28:05+00:00Added an answer on June 7, 2026 at 1:28 pm

    By static analysis, it loops forever because your while True never breaks. So where can it break? Only at the break statement only if the next_encounter becomes equal to -1; so you can deduce that it never does.

    Why doesn’t it? Try a print next_encounter after url.find. You’ll quickly see that

    url = url[next_encounter:]
    

    does almost what you hope it will, only it gives you one character more than you hoped.

    Why did I present it this way? Mostly because the value of print is often underrated by people learning the language.

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

Sidebar

Related Questions

I am in the process of writing some validation code based on these assumptions:
In the process of writing an Off By One mutation tester for my favourite
Let's say you had an external process writing files to some directory, and you
Im in the process of writing a python script to act as a glue
I'm in the process of writing an application to suggest circular routes over OpenStreetMap
I'm in the process of writing a small text-editor that is supposed to have
I am in the process of writing a small WordPress data sync plugin that
I am in the process of writing an enterprise-level application utilizing WCF and NetTCP
I'm in the process of writing a smart pointer countedptr and I've hit a
I'm in the process of writing a jQuery plugin, and am getting into some

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.