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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:37:02+00:00 2026-06-13T05:37:02+00:00

I am having trouble with a program in python…I need the program to jumble

  • 0

I am having trouble with a program in python…I need the program to jumble the middle of words while keeping the outer two letters intact…I believe I have successfully split the word into three different sections, I just can’t figure out how I am supposed to scramble the middle of the word

word = input("Enter a word")

first_letter = word[0]

last_letter = word[-1]

still_to_scramble = word[1:-1]

Should I use randoms? Or is there a simple way, sorry I am relatively new to coding.

  • 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-13T05:37:03+00:00Added an answer on June 13, 2026 at 5:37 am

    You can use shuffle from the random package:

    import random
    letters = list(still_to_scramble)
    random.shuffle(letters)
    scrambled = ''.join(letters)
    

    Here’s how it would work:

    >>> s
    '$123abc$'
    >>> first_letter = s[0]
    >>> last_letter = s[-1]
    >>> middle_parts = list(s[1:-1])
    >>> random.shuffle(middle_parts)
    >>> ''.join(middle_parts)
    'b3a2c1'
    

    Be careful and don’t do this:

    >>> middle_parts_random = random.shuffle(middle_parts)
    

    shuffle works in place – that’s a fancy way of saying it does’t return the shuffled bit, but modifies it instead. It actually returns None, and you may get tripped up by it, since you won’t see an error:

    >>> middle_parts_random = random.shuffle(middle_parts)
    >>> middle_parts_random # Huh? nothing is printed!
    >>> middle_parts_random == None # Ah, that's why. Darn you in-place methods!
    True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning python and am having trouble getting this program to work correctly.
I am having trouble compiling a program I have written. I have two different
I'm having trouble getting started with SublimeREPL. I have a python program, and can
I am having trouble building a basic spider program in Python. Whenever I try
I'm having trouble displaying content, my program: #! /usr/bin/python import urllib import re url
I'm having trouble writing a simple Python program for a beginner programming class. If
For some reason I'm having trouble getting my program to run a while loop.
I have been having some trouble with my Python program. Basically, it is a
I'm using the python optparse module in my program, and I'm having trouble finding
I'm having trouble getting command line arguments passed to Python programs if I try

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.