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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:55:27+00:00 2026-06-13T15:55:27+00:00

Possible Duplicate: Python splitting strings and jumbling the middle I have a program in

  • 0

Possible Duplicate:
Python splitting strings and jumbling the middle

I have a program in python that I am really stuck on, my purpose of this is to take a sentence from a user and jumble the middle of the word leaving the outer to letters intact…My teacher says I need to do something with parameters but I really have no clue how too access or use my function at all…

import random


user_words = input("Enter a word or sentence: ") #Gets user input

word = list(user_words.split()) #Creating a word list of the user input


def Jumble_One_Word(x):

    if len(user_words) > 2: #Only need to change words longer than 2

      first_letter = user_words[0] #Takes the first letter out and defines it

      last_letter = user_words[-1] #Takes the last letter out and defines it

      letters = list(user_words[1:-1]) #Takes the rest and puts them into a list

      random.shuffle(letters) #shuffles the list above

      middle_letters = "".join(letters) #Joins the shuffled list

      final_word = "".join([first_letter, middle_letters, last_letter]) #Puts final      word all back  in place as a list

    print(final_word)#Prints out the final word all back together again


Jumbler_Count = -1

for i in range(len(word)):
    Jumbler_Count + 1
    Word1 = Jumble_One_Word(word[Jumbler_Count])

SAMPLE INPUT: HELLO MY NAME IS
EXPECTED OUTPUT: HLELO MY NMAE IS
RESULTED OUTPUT: H leai El moymns
Hoi ynmeEa lm ls
Hiyn l oelEamms
H naellmEyo m is

  • 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-13T15:55:29+00:00Added an answer on June 13, 2026 at 3:55 pm

    you need to work on x inside the function, and you were working on user_words instead.

    import random
    
    user_words = input("Enter a word or sentence: ") #Gets user input
    
    word = user_words.split()  #no need of list()
    
    def Jumble_One_Word(x):
    
        if len(x) > 2: #Only need to change words longer than 2
    
    
          first_letter = x[0] #Takes the first letter out and defines it
    
          last_letter = x[-1] #Takes the last letter out and defines it
    
          letters = list(x[1:-1]) #Takes the rest and puts them into a list
    
          random.shuffle(letters) #shuffles the list above
    
          middle_letters = "".join(letters) #Joins the shuffled list
    
          final_word = "".join([first_letter, middle_letters, last_letter]) #Puts finalword all back  in place as a list
    
          return final_word # better return from function inste
    
    
    for i in word:                 #you can iterate this way too
        print (Jumble_One_Word(i))
    

    output:

    $ python3 abc.py
    Enter a word or sentence: python guido spam
    pyhton
    giudo
    sapm
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: python dict.add_by_value(dict_2) ? My input is two dictionaries that have string keys
Possible Duplicate: Getting python.exe path at run time I have a python app that
Possible Duplicate: Python: Split string with multiple delimiters I have a program where I
Possible Duplicate: Splitting a string into a list in python I'd like to take
Possible Duplicate: Python ‘==’ vs ‘is’ comparing strings, ‘is’ fails sometimes, why? Is a
Possible Duplicate: Python ‘==’ vs ‘is’ comparing strings, ‘is’ fails sometimes, why? In Python,
Possible Duplicate: Python or Ruby Interpreter on iOS I just discovered this apps pypad
Possible Duplicate: Python, compute list difference I have two lists For example: A =
Possible Duplicate: Strip html from strings in python While making a small browser like
Possible Duplicate: Python: simple list merging based on intersections I have a multiple list:

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.