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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:57:00+00:00 2026-05-26T23:57:00+00:00

This is a homework assignment. I just need a nudge. I’m trying to create

  • 0

This is a homework assignment. I just need a nudge.

I’m trying to create a loop in which the letters of a string will be removed when it is beyond a certain number.

Example:

Enter Your String: David
Enter Your Amount: 4
Returns: Davi

What I’ve made so far:

word = raw_input("Enter your string:")
amount = raw_input("Enter your amount:")
word_length = len(word)

if word_length > amount:
  for i in range(word_length):
    if s[i] > amount:

And that’s just about as far as I’ve gotten. I’m not very sure as to which syntax I use to delete the letters that are in positions greater than word_length.

  • 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-26T23:57:00+00:00Added an answer on May 26, 2026 at 11:57 pm

    A string itself in Python is immutable — it cannot be changed and letters cannot be deleted. But you can create new string objects based on your string. One way of doing so is slicing.

    Read through the linked section of the official Python tutorial until you find what you need. 🙂

    Edit: If you need to use a loop, as suggested in your comment, another technique is also possible:

    1. Create an empty list.

    2. Loop over the indices range(amount) and add the letter corresponding to the current index to your list.

    3. Join the list to a string again using "".join(my_list).

    The purpose of the iterim list is that a list can be altered, while a string — as said before — is immutable.

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

Sidebar

Related Questions

Yes, this is homework. I completed the assignment in it's entirety. Just need to
Working on a homework assignment and am stuck with this task: Create a loop
I'm doing a basic homework assignment which looks like this: While input <> -1
I need little help on a homework assignment. I have to create a 10
I have been given a homework assignment where I need to create a captcha
This is a homework assignment, just for all that want to know. I'm writing
(No, this isn't a homework assignment, I just found the bug and thought it
This is a homework assignment, so I'm mostly asking for a nudge in the
This is part of a homework assignment. I've got several questions asking find the
Disclaimer: This is for a homework assignment, but the question is not regarding the

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.