473,471 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I hide the answer given to a raw_input (and replace it with stars)?

1 New Member
Hi!
Long story short; I'm doing a bit more advanced version of the classic game Hangman. You play with a friend and the thing is that you could see what word your friend had inserted in the raw_input.
Now I want to replace every letter in the chosen word into a star(*) so that you can't see the secret word anywere.
I'd appreciate it if you'd write the code in the answer.

Thanks in advance.
Jun 3 '12 #1
1 2096
bvdet
2,851 Recognized Expert Moderator Specialist
I don't know a way using raw_input, but you can do it with Tkinter. Example:
Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  2.  
  3. textFont1 = ("Arial", 16, "normal")
  4.  
  5. class EntryWidget(Tkinter.Entry):
  6.     def __init__(self, master, initial=""):
  7.         Tkinter.Entry.__init__(self, master=master)
  8.         self.value = Tkinter.StringVar()
  9.         self.config(textvariable=self.value, width=20,
  10.                     relief="sunken", font=textFont1,
  11.                     bg="#eee", fg="#000",
  12.                     justify='center',
  13.                     show="*")
  14.         self.pack()
  15.         self.value.set(initial)
  16.  
  17. class App(Tkinter.Tk):
  18.     def __init__(self, title="Hidden Entry"):
  19.         Tkinter.Tk.__init__(self)
  20.         self.title(title)
  21.         self.w = EntryWidget(self)
  22.         self.mainloop()
  23.         self.value = self.w.value.get()
  24.  
  25. if __name__ == "__main__":
  26.     app = App()
  27.     print app.value
Jun 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Cortes | last post by:
Hi all, Suppose I want to add 1 single line: <script src = "/sample.js" type="text/javascript"></script> to every single webpage ( preferrably right after the tag <head>) under the root...
4
by: lucky | last post by:
hi there!! i'm looking for a code snipett wich help me to search some words into a particular string and replace with a perticular word. i got a huge data string in which searching traditional...
13
by: Murali | last post by:
Given: L = list of integers. X and Y are integers. Problem: find every occurence of X and replace with Y Solution1: def check(s): if s==X: return Y else return s newL =
5
by: nayeef | last post by:
hello there i want to know a program which will find find a given variable in a list and replace/delete them according to our wish. Well it would be preferable if its in C. thanks
2
by: vinkumar | last post by:
Hi, I have to search for string and replace with user input value using js. I have used inner HTML (objExplorer.Document.body.innerHTML) to get user input. (Eg: If user inputs web port no. as...
12
by: pharstvedt | last post by:
I am trying to execute a perl one-liner to find and replace text without much luck. I think it is because my strings have so many spaces. This is the command: find J:\testing\1 -name 'ap160ws'...
6
by: Raju Sathliya | last post by:
I have writen a small script to replace the . with /../ which is as follows. $var = "DataAccess\DataAccess."; $var =~ s/(.)/(\)..(\)/; print "value is : $var"; But in this case when I run...
6
by: chrispoliquin | last post by:
I am using regular expressions to search a string (always full sentences, maybe more than one sentence) for common abbreviations and remove the periods. I need to break the string into different...
7
by: abcmavdi | last post by:
I want to write a code which replace words from string.without use of string function in c language. Example str = "This is string" remove "is" from string and replace with "was". so, finally str...
2
by: anii | last post by:
Hi there, I've got this piece of code, but I'm having trouble getting it to write the changes into the file. What I'm trying to do is: Read text file Find user specified character (eg. what...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.