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

The Archive Base Latest Questions

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

I am currently building a MUD (Multi-User-Domain) for an rpg game. Doing this entirely

  • 0

I am currently building a MUD (Multi-User-Domain) for an rpg game. Doing this entirely in Python to both make a game I enjoy, and learn python. A problem I am running in to, and due to the extreme specificity of the question, I’ve been unable to find the right answer.

So, here’s what I need, in a nut-shell. I don’t have a good snippet of code that fully shows what I need as I’d have to paste about 50 lines to have to 5 lines I’m using make sense.

targetOptions = ['Joe', 'Bob', 'zombie', 'Susan', 'kobold', 'Bill']

A cmd in our game is attack, where we type ‘a zombie’ and we then proceed to kill the zombie. However, I want to just type ‘a z’. We’ve tried a few different things in our code, but they’re all unstable and often just wrong. One of our attempts returned something like [‘sword’, ‘talisman’] as matches for ‘get sword’. So, is there a way to search this list and have it return a matched value?

I also need to just return value[0] if there are say, 2 zombies in the room and I type ‘a z’. Thanks for all your help ahead of time, and I hope I was clear enough for what I’m looking for. Please let me know if more info is needed. And don’t worry about the whole attacking thing, I just need to send ‘zo’ and get ‘zombie’ or something similar. Thanks!

  • 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-07T05:28:40+00:00Added an answer on June 7, 2026 at 5:28 am

    Welcome to SO and Python! I suggest you take a look at the official Python documentation and spend some time looking around what’s included in the Python Standard Library.

    The difflib module contains a function get_close_matches() that can help you with approximate string comparisons. Here’s how it looks like:

    from difflib import get_close_matches

    def get_target_match(target, targets):
        '''
        Approximates a match for a target from a sequence of targets,
        if a match exists.
        '''
        source, targets = targets, map(str.lower, targets)
        target = target.lower()
    
        matches = get_close_matches(target, targets, n=1, cutoff=0.25)
    
        if matches:
            match = matches[0]
            return source[targets.index(match)]
        else:
            return None
    
    target = 'Z'
    targets = ['Joe', 'Bob', 'zombie', 'Susan', 'kobold', 'Bill']
    match = get_target_match(target, targets)
    print "Going nom on %s" % match # IT'S A ZOMBIE!!!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently building this hierarchy of objects and to be able to make the logging
I'm currently building a user control that displays a message when a Repeater is
I'm currently building a web application that has multiple user types, where users engage
I'm currently building a Rails app, where a user can upload an mp3 and
I'm currently building a Web Service that sends files this also obtains the mime-type
I'm currently building a job-board website with CodeIgniter 2.0 that is very user content
I'm currently building a project and I would like to make use of some
I´m currently building an Android app, which tracks the user´s location. My aim is
Currently building a WPF app that will run in an environment where the user
I am currently building my project locally using MVC. The user enters some search

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.