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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:47:45+00:00 2026-06-07T19:47:45+00:00

I wrote a python script which just stopped working suddenly. I’m not sure why

  • 0

I wrote a python script which just stopped working suddenly. I’m not sure why so any help would be appreciated. The console just doesn’t display anything. I called the function start on the bottom but no luck.

import random

year = 1
our_score = 0
their_score = 0
games_played = 0

#opponent's strategy:
def op_strategy():
    for i in range (0,1):
        rand = random.randint(0,1)
    if rand == 0:
        return "war"
    if rand == 1:
        return "peace"


def start():
    global our_score, their_score, year
    print "====="
    print "Year " + str(year)
    print "Our Score: " + str(our_score)
    print "Their Score: " + str(their_score)
    print ""
    strategy = raw_input("What is your strategy this year? ")
    inputs(strategy)

def inputs(strategy):
    our_score = 0
    global our_score, their_score, year
    if str(strategy) == "peace" or str(strategy) == "war":
        print "You chose: " + str(strategy)
        op_strat = str(op_strategy())
        print "They chose: " + op_strat
    if str(strategy) == "war" and str(op_strat) == "war":
        print ">>> Everyoner to arms!"
        our_score = our_score + 1
        their_score = their_score + 1
        year = year + 1
    elif str(strategy) == "peace" and str(op_strat) == "peace":
        print ">>> Peace for everyone!"
        our_score = our_score + 3
        their_score = their_score + 3
        year = year + 1
    elif str(strategy) == "peace" and str(op_strat) == "war":
        print ">>> They crushed us!"
        our_score = our_score
        their_score = their_score + 5
        year = year + 1
    elif str(strategy) == "war" and str(op_strat) == "peace":
        print ">>> We crushed them!"
        our_score = our_score + 5
        their_score = their_score
        year = year + 1
    if str(year) == "11":
        print "====="
        print "Final"
        print str(our_score)
        print str(their_score)
        if our_score > their_score:
            print ">>>>> We win! <<<<<"
        if their_score > our_score:
            print ">>>>> They win! <<<<<"
        if their_score == our_score:
            print ">>>>> It's a tie! <<<<<"
        play = raw_input("Play again?")
        if play == "y":
            start()
        if play == "n":
            pass
        else:
            play = raw_input('Invalid response. Please enter "y" or "n".')
    if str(strategy) != "peace" and str(strategy) != "war":
        strategy = raw_input('Invalid strategy. Enter "peace" or "war": ')
        inputs(strategy)
    start()
start()
  • 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-07T19:47:47+00:00Added an answer on June 7, 2026 at 7:47 pm

    The code is executing, but it is stuck at the raw_input call, and not printing until it completes, which of course the user does not know to do because nothing has printed.
    The buffer is not automatically flushed. If you start python with the -u option, the buffer will be flushed with the raw_input call, and the prompt will be apparent.

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

Sidebar

Related Questions

I wrote the following script, which generates a SyntaxError : #!/usr/bin/python print Enter the
I'm just beginning to learn python. I wrote an example script to test OOP
I've a python script which works just as it should, but I need to
So I wrote a Python script which does some simple stuff. It was originally
I wrote a little Python script wrapcl.py script which wraps our compiler binary (
I wrote a Python script that does some task to generate, and then keep
I wrote a Python GUI script with Tkinter, and now I want to convert
I would like to write a python script that takes a bunch of swf
I have a python script running on a cron job, once a minute, which
I'm currently working on a script which extracts data from two sources where one

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.