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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:33:13+00:00 2026-05-31T01:33:13+00:00

I have made a hangman game in Python, and stupidly didn’t save as before

  • 0

I have made a hangman game in Python, and stupidly didn’t save as before I tried using curses. 😐 Now, the body of the man is displayed in different spots. The head and arms are before the pole that holds the top up, and the body and the legs are where they should be. Here’s my code. It’s probably the ugliest code I have written in Python…

import random
import re
import curses

myscreen = curses.initscr()
myscreen.clear()
myscreen.border(0)
myscreen.refresh()

f = open("/usr/share/dict/words", "r")
c = f.read().split('\n')
d = {1:'o', 2:'\\o/', 3:'\n      |     \\o/\n      |      |', 4:'\n      |      \\o/\n      |      |\n      |     / \\'}
w = random.choice(c).lower()
i = 1
j = 6
n = []
t = []
b = ""
l=4
h=2

myscreen.addstr(2,6, "--------")
myscreen.addstr(3,6, "|")
myscreen.addstr(3,13, "|"+b)
for item in range(j+1):
  myscreen.addstr(l, 2, "    |\n")
  l=l+1

myscreen.addstr(9,2,"__________\n")

for char in w:
  n.append('_')

for item in n:
  myscreen.addstr(10, h, item,)
  h=h+2

myscreen.addstr(11, 2, '\n')
myscreen.refresh()

while n != w:
  if not re.findall('_', ''.join(n)):
    myscreen.clear()
    myscreen.addstr(1,1, "You win!!\n\n")
    myscreen.refresh()
    break
  myscreen.addstr(12,2,"Guess: ")
  g = myscreen.getstr(12,9,1)
  if 1:
    if g in ''.join(t):
      print "You already guessed that."
      continue
    if g in w:
     k = [match.start() for match in re.finditer(re.escape(g), w)]
     for item in k:
       n[item]=g
     t.append(g)
    else:
      if i!=5:
        b = d[i]
        i=i+1
        j=j-1
        t.append(g)
      else:
        myscreen.clear()
        myscreen.addstr(1, 1, "You lose!")
        myscreen.addstr(2, 1, "The word was %s.\n\n" % w)
        myscreen.refresh()
        break
    myscreen.clear()
    myscreen.addstr(2,6, "--------")
    myscreen.addstr(3,6, "|")
    myscreen.addstr(3,13, "|\n"+b)
    l=4
    for item in range(j):
      myscreen.addstr(l, 6, "|\n")
      l=l+1

    myscreen.addstr(9,2,"__________\n")
    l=2
    for item in t:
      myscreen.addstr(10, l, item)
      l=l+2
    l=2
    for item in n:
      myscreen.addstr(11, l, item)
      l=l+2
    myscreen.refresh()
  else:
    myscreen.addstr(12, 2, "Please enter a letter.")
    myscreen.refresh()

What is wrong with it?

  • 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-05-31T01:33:14+00:00Added an answer on May 31, 2026 at 1:33 am

    D’oh! I was doing the for loop after I had placed the pole that holds it up there already, so it “overwrote” the previous one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a multiplayer game using the GameKit Framework where 2 iPhones/iPods can
i have made an application using python and google app engine, the app works
I have made a new windows service which works fine using barebone code (just
I have made an application (for my self) for feeds reading, using SyndicationFeed ,
I have made a very simple Pie Graph generator using Javascript & SVG graphics.
I have made a table using GtkTable and in that table I have attached
I have made a setup and deployment project in C#, Now i have another
I have made some helper functions that run a simulation using a lot of
I have made an Axis2 Web Service in Java. I am using Apache Tomcat
I have made this game for Mac OS, but I realised that i need

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.