Hangman help: invalid print statement









up vote
-6
down vote

favorite












My Hangman code has errors on line 40 , line 40



print ('_'+ end=' ')


My code:



import time
import random
print('Lets play hangman')
print("""
_______
| |
| O
| |
| - -/
| |
| | |
| | |
____|____
""")



random_words = ['string', 'loop', 'python', 'print', 'run' , 'graphics window', 'variable', 'iteration', 'modules', 'module', 'input', 'logic', 'output ']
time.sleep(2)
print ("What level would you like to play at? Too bad, you get random! Better type it in tho...")
level_of_difficulty = "Random"
time.sleep(2)
print ("The program is now generating your word...")
if level_of_difficulty == 'Random':
generated_word = random.choice(random_words)

guessed = ''

lives = 7


while lives > 0:

missed = 0
print()
for letter in generated_word:
if letter in guessed:
print("Congrats ya dumb animal, you got one")
else:
print ('_'+ end=' ')
missed = missed + 1
if missed == 0:
print ('nnYou win!')
quit()
break
guess=input("Well what are you waiting for? guess a letter!:")

guessed = guessed + guess
if guess not in generated_word:
print ('n People like you are the reason why the human race will fail')
print ('Fool')
lives = lives - 1
missed = missed + 1

print('your new lives value is ' + str(lives))

if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | - -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | | | ')
if lives < 1:
print(' | | | ')
if lives == 0:
print('___|___ ')

print('Game Over Boi')
print('The secret word was ' + str(generated_word) + "fool")
quit()









share|improve this question























  • what version of python are you using, and what is the exact error message?
    – wpercy
    Nov 9 at 19:51










  • lemme check on that
    – Timothy Johnson
    Nov 9 at 19:51






  • 3




    Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
    – Kenneth K.
    Nov 9 at 19:51






  • 3




    @TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
    – Tilman B. aka Nerdyyy
    Nov 9 at 19:52






  • 1




    @TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
    – wpercy
    Nov 9 at 19:57














up vote
-6
down vote

favorite












My Hangman code has errors on line 40 , line 40



print ('_'+ end=' ')


My code:



import time
import random
print('Lets play hangman')
print("""
_______
| |
| O
| |
| - -/
| |
| | |
| | |
____|____
""")



random_words = ['string', 'loop', 'python', 'print', 'run' , 'graphics window', 'variable', 'iteration', 'modules', 'module', 'input', 'logic', 'output ']
time.sleep(2)
print ("What level would you like to play at? Too bad, you get random! Better type it in tho...")
level_of_difficulty = "Random"
time.sleep(2)
print ("The program is now generating your word...")
if level_of_difficulty == 'Random':
generated_word = random.choice(random_words)

guessed = ''

lives = 7


while lives > 0:

missed = 0
print()
for letter in generated_word:
if letter in guessed:
print("Congrats ya dumb animal, you got one")
else:
print ('_'+ end=' ')
missed = missed + 1
if missed == 0:
print ('nnYou win!')
quit()
break
guess=input("Well what are you waiting for? guess a letter!:")

guessed = guessed + guess
if guess not in generated_word:
print ('n People like you are the reason why the human race will fail')
print ('Fool')
lives = lives - 1
missed = missed + 1

print('your new lives value is ' + str(lives))

if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | - -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | | | ')
if lives < 1:
print(' | | | ')
if lives == 0:
print('___|___ ')

print('Game Over Boi')
print('The secret word was ' + str(generated_word) + "fool")
quit()









share|improve this question























  • what version of python are you using, and what is the exact error message?
    – wpercy
    Nov 9 at 19:51










  • lemme check on that
    – Timothy Johnson
    Nov 9 at 19:51






  • 3




    Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
    – Kenneth K.
    Nov 9 at 19:51






  • 3




    @TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
    – Tilman B. aka Nerdyyy
    Nov 9 at 19:52






  • 1




    @TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
    – wpercy
    Nov 9 at 19:57












up vote
-6
down vote

favorite









up vote
-6
down vote

favorite











My Hangman code has errors on line 40 , line 40



print ('_'+ end=' ')


My code:



import time
import random
print('Lets play hangman')
print("""
_______
| |
| O
| |
| - -/
| |
| | |
| | |
____|____
""")



random_words = ['string', 'loop', 'python', 'print', 'run' , 'graphics window', 'variable', 'iteration', 'modules', 'module', 'input', 'logic', 'output ']
time.sleep(2)
print ("What level would you like to play at? Too bad, you get random! Better type it in tho...")
level_of_difficulty = "Random"
time.sleep(2)
print ("The program is now generating your word...")
if level_of_difficulty == 'Random':
generated_word = random.choice(random_words)

guessed = ''

lives = 7


while lives > 0:

missed = 0
print()
for letter in generated_word:
if letter in guessed:
print("Congrats ya dumb animal, you got one")
else:
print ('_'+ end=' ')
missed = missed + 1
if missed == 0:
print ('nnYou win!')
quit()
break
guess=input("Well what are you waiting for? guess a letter!:")

guessed = guessed + guess
if guess not in generated_word:
print ('n People like you are the reason why the human race will fail')
print ('Fool')
lives = lives - 1
missed = missed + 1

print('your new lives value is ' + str(lives))

if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | - -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | | | ')
if lives < 1:
print(' | | | ')
if lives == 0:
print('___|___ ')

print('Game Over Boi')
print('The secret word was ' + str(generated_word) + "fool")
quit()









share|improve this question















My Hangman code has errors on line 40 , line 40



print ('_'+ end=' ')


My code:



import time
import random
print('Lets play hangman')
print("""
_______
| |
| O
| |
| - -/
| |
| | |
| | |
____|____
""")



random_words = ['string', 'loop', 'python', 'print', 'run' , 'graphics window', 'variable', 'iteration', 'modules', 'module', 'input', 'logic', 'output ']
time.sleep(2)
print ("What level would you like to play at? Too bad, you get random! Better type it in tho...")
level_of_difficulty = "Random"
time.sleep(2)
print ("The program is now generating your word...")
if level_of_difficulty == 'Random':
generated_word = random.choice(random_words)

guessed = ''

lives = 7


while lives > 0:

missed = 0
print()
for letter in generated_word:
if letter in guessed:
print("Congrats ya dumb animal, you got one")
else:
print ('_'+ end=' ')
missed = missed + 1
if missed == 0:
print ('nnYou win!')
quit()
break
guess=input("Well what are you waiting for? guess a letter!:")

guessed = guessed + guess
if guess not in generated_word:
print ('n People like you are the reason why the human race will fail')
print ('Fool')
lives = lives - 1
missed = missed + 1

print('your new lives value is ' + str(lives))

if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | - -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | | | ')
if lives < 1:
print(' | | | ')
if lives == 0:
print('___|___ ')

print('Game Over Boi')
print('The secret word was ' + str(generated_word) + "fool")
quit()






python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 19:55









Prune

41.1k133454




41.1k133454










asked Nov 9 at 19:48









Timothy Johnson

12




12











  • what version of python are you using, and what is the exact error message?
    – wpercy
    Nov 9 at 19:51










  • lemme check on that
    – Timothy Johnson
    Nov 9 at 19:51






  • 3




    Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
    – Kenneth K.
    Nov 9 at 19:51






  • 3




    @TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
    – Tilman B. aka Nerdyyy
    Nov 9 at 19:52






  • 1




    @TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
    – wpercy
    Nov 9 at 19:57
















  • what version of python are you using, and what is the exact error message?
    – wpercy
    Nov 9 at 19:51










  • lemme check on that
    – Timothy Johnson
    Nov 9 at 19:51






  • 3




    Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
    – Kenneth K.
    Nov 9 at 19:51






  • 3




    @TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
    – Tilman B. aka Nerdyyy
    Nov 9 at 19:52






  • 1




    @TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
    – wpercy
    Nov 9 at 19:57















what version of python are you using, and what is the exact error message?
– wpercy
Nov 9 at 19:51




what version of python are you using, and what is the exact error message?
– wpercy
Nov 9 at 19:51












lemme check on that
– Timothy Johnson
Nov 9 at 19:51




lemme check on that
– Timothy Johnson
Nov 9 at 19:51




3




3




Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
– Kenneth K.
Nov 9 at 19:51




Well, you haven't actually asked a question. You've basically just said, "here's my code, figure out what's wrong." What you should do instead is say, here's my code; i'm getting an error on line XXX, and here's the error message, and here's what I've tried to do to fix it. In other words: stackoverflow.com/help/how-to-ask
– Kenneth K.
Nov 9 at 19:51




3




3




@TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
– Tilman B. aka Nerdyyy
Nov 9 at 19:52




@TimothyJohnson hate is the wrong word, but there are a few things wrong with your post. firstly: please include a Minimal Complete Verifiable Example (the only thing missing is the minimal part). secondly, don't call for sympathy with phrases like "I'm new to $Language or $Concept". thirdly, include the errors you're getting, don't just say that you're getting errors. and, lastly: don't ever write things like please help me, um... yeah.
– Tilman B. aka Nerdyyy
Nov 9 at 19:52




1




1




@TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
– wpercy
Nov 9 at 19:57




@TimothyJohnson if you're using python 2.x you can't pass end= as an argument to the print function.
– wpercy
Nov 9 at 19:57












1 Answer
1






active

oldest

votes

















up vote
0
down vote














so here is some code that partially belongs to me




This appears to be the root of the problem. The main issue aside from a type is the use of Python 3 functionality when you are using Python 2.



print ('_'+ end=' ')


Aside from the typo that + needs to be a ,. In Python 2 the end keyword is not used for print, which is only used in python 3. Instead you can do the same thing in Python 2 by doing:



print '_',


The next issue will be with line:



guess=input("Well what are you waiting for? guess a letter!:")


This will give you a error because in Python 2 it tries to evaluate what you entered as an expression instead of a string. Instead you will need to do:



guess=raw_input("Well what are you waiting for? guess a letter!:")


With both these fixes you will have a working game. Although you may want to add in a way to see what letters the user got right.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232385%2fhangman-help-invalid-print-statement%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote














    so here is some code that partially belongs to me




    This appears to be the root of the problem. The main issue aside from a type is the use of Python 3 functionality when you are using Python 2.



    print ('_'+ end=' ')


    Aside from the typo that + needs to be a ,. In Python 2 the end keyword is not used for print, which is only used in python 3. Instead you can do the same thing in Python 2 by doing:



    print '_',


    The next issue will be with line:



    guess=input("Well what are you waiting for? guess a letter!:")


    This will give you a error because in Python 2 it tries to evaluate what you entered as an expression instead of a string. Instead you will need to do:



    guess=raw_input("Well what are you waiting for? guess a letter!:")


    With both these fixes you will have a working game. Although you may want to add in a way to see what letters the user got right.






    share|improve this answer


























      up vote
      0
      down vote














      so here is some code that partially belongs to me




      This appears to be the root of the problem. The main issue aside from a type is the use of Python 3 functionality when you are using Python 2.



      print ('_'+ end=' ')


      Aside from the typo that + needs to be a ,. In Python 2 the end keyword is not used for print, which is only used in python 3. Instead you can do the same thing in Python 2 by doing:



      print '_',


      The next issue will be with line:



      guess=input("Well what are you waiting for? guess a letter!:")


      This will give you a error because in Python 2 it tries to evaluate what you entered as an expression instead of a string. Instead you will need to do:



      guess=raw_input("Well what are you waiting for? guess a letter!:")


      With both these fixes you will have a working game. Although you may want to add in a way to see what letters the user got right.






      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote










        so here is some code that partially belongs to me




        This appears to be the root of the problem. The main issue aside from a type is the use of Python 3 functionality when you are using Python 2.



        print ('_'+ end=' ')


        Aside from the typo that + needs to be a ,. In Python 2 the end keyword is not used for print, which is only used in python 3. Instead you can do the same thing in Python 2 by doing:



        print '_',


        The next issue will be with line:



        guess=input("Well what are you waiting for? guess a letter!:")


        This will give you a error because in Python 2 it tries to evaluate what you entered as an expression instead of a string. Instead you will need to do:



        guess=raw_input("Well what are you waiting for? guess a letter!:")


        With both these fixes you will have a working game. Although you may want to add in a way to see what letters the user got right.






        share|improve this answer















        so here is some code that partially belongs to me




        This appears to be the root of the problem. The main issue aside from a type is the use of Python 3 functionality when you are using Python 2.



        print ('_'+ end=' ')


        Aside from the typo that + needs to be a ,. In Python 2 the end keyword is not used for print, which is only used in python 3. Instead you can do the same thing in Python 2 by doing:



        print '_',


        The next issue will be with line:



        guess=input("Well what are you waiting for? guess a letter!:")


        This will give you a error because in Python 2 it tries to evaluate what you entered as an expression instead of a string. Instead you will need to do:



        guess=raw_input("Well what are you waiting for? guess a letter!:")


        With both these fixes you will have a working game. Although you may want to add in a way to see what letters the user got right.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 9 at 20:38

























        answered Nov 9 at 20:33









        Spencer Wieczorek

        17.3k43043




        17.3k43043



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232385%2fhangman-help-invalid-print-statement%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kleinkühnau

            Makov (Slowakei)

            Deutsches Schauspielhaus