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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:54:46+00:00 2026-06-13T03:54:46+00:00

Possible Duplicate: Python read a single character from the user I am using below

  • 0

Possible Duplicate:
Python read a single character from the user

I am using below code.But instead of accepting a single character its allowing user to put more than a single character.

How can I fix that?

guess = raw_input(':')
guessInLower = guess.lower()
  • 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-13T03:54:47+00:00Added an answer on June 13, 2026 at 3:54 am

    The following will continuously prompt the user for input until they enter exactly one character.

    userInput = ''
    while len(userInput) != 1:
        userInput = raw_input(':')
    guessInLower = userInput.lower()
    

    This does the same, but also informs them of the one character limit before prompting again for input

    while True:
        userInput = raw_input(':')
        if len(userInput) == 1:
            break
        print 'Please enter only one character'
    guessInLower = userInput.lower()
    

    It looks like you are expecting only letters. If that is the case you can expand this further to require that:

    import string
    
    while True:
        userInput = raw_input(':')
        if len(userInput) == 1:
            if userInput in string.letters:
                break
            print 'Please enter only letters'
        else:
            print 'Please enter only one character'
    guessInLower = userInput.lower()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Python read a single character from the user I am looking to
Possible Duplicate: Python code to pick out all possible combinations from a list? I
Possible Duplicate: reading integers from binary file in python I've read the solution to
Possible Duplicate: How do you read from stdin in python I am new Python
Possible Duplicate: Python: Retrieve items from a set Consider the following code: >>> item1
Possible Duplicate: Set undefined javascript property before read Is there an equivalent of Python's
Possible Duplicate: python takes list and returns only if negative value also exists using
Possible Duplicate: Python ‘self’ explained I have looked for some time but i still
Possible Duplicate: Python: How to read huge text file into memory To process a
Possible Duplicate: How do I read a date in Excel format in Python? I

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.