Space Invaders Syntax error on last line of code and random letter on python 3.7 [duplicate]












0















This question already has an answer here:




  • Syntax error when defining a function on the Python command line

    4 answers




beginner here, I was trying to create a space invaders program in Python 3.7, but when I try to run this script in the terminal, it gives me this error:



border_pen.hideturtle()
^


SyntaxError: invalid syntax



Full script:



import turtle
import os

wn = turtle.Screen()
wn.bgcolor("black")
wn.title("Space Invaders")

delay = input("Press enter to finish.")

border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300,-300)
border_pen.pensize(3)
border_pen.pendown()
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()









share|improve this question















marked as duplicate by Thierry Lathuille, khelwood python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 at 8:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 3




    Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
    – Andras Deak
    Nov 23 at 7:34






  • 1




    It does not give an error when I run just the program is crashing
    – Rarblack
    Nov 23 at 7:37










  • If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
    – Thierry Lathuille
    Nov 23 at 7:56
















0















This question already has an answer here:




  • Syntax error when defining a function on the Python command line

    4 answers




beginner here, I was trying to create a space invaders program in Python 3.7, but when I try to run this script in the terminal, it gives me this error:



border_pen.hideturtle()
^


SyntaxError: invalid syntax



Full script:



import turtle
import os

wn = turtle.Screen()
wn.bgcolor("black")
wn.title("Space Invaders")

delay = input("Press enter to finish.")

border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300,-300)
border_pen.pensize(3)
border_pen.pendown()
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()









share|improve this question















marked as duplicate by Thierry Lathuille, khelwood python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 at 8:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 3




    Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
    – Andras Deak
    Nov 23 at 7:34






  • 1




    It does not give an error when I run just the program is crashing
    – Rarblack
    Nov 23 at 7:37










  • If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
    – Thierry Lathuille
    Nov 23 at 7:56














0












0








0








This question already has an answer here:




  • Syntax error when defining a function on the Python command line

    4 answers




beginner here, I was trying to create a space invaders program in Python 3.7, but when I try to run this script in the terminal, it gives me this error:



border_pen.hideturtle()
^


SyntaxError: invalid syntax



Full script:



import turtle
import os

wn = turtle.Screen()
wn.bgcolor("black")
wn.title("Space Invaders")

delay = input("Press enter to finish.")

border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300,-300)
border_pen.pensize(3)
border_pen.pendown()
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()









share|improve this question
















This question already has an answer here:




  • Syntax error when defining a function on the Python command line

    4 answers




beginner here, I was trying to create a space invaders program in Python 3.7, but when I try to run this script in the terminal, it gives me this error:



border_pen.hideturtle()
^


SyntaxError: invalid syntax



Full script:



import turtle
import os

wn = turtle.Screen()
wn.bgcolor("black")
wn.title("Space Invaders")

delay = input("Press enter to finish.")

border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300,-300)
border_pen.pensize(3)
border_pen.pendown()
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()




This question already has an answer here:




  • Syntax error when defining a function on the Python command line

    4 answers








python python-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 7:30









khelwood

30.1k74162




30.1k74162










asked Nov 23 at 7:27









Capkey Studios

41




41




marked as duplicate by Thierry Lathuille, khelwood python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 at 8:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Thierry Lathuille, khelwood python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 at 8:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 3




    Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
    – Andras Deak
    Nov 23 at 7:34






  • 1




    It does not give an error when I run just the program is crashing
    – Rarblack
    Nov 23 at 7:37










  • If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
    – Thierry Lathuille
    Nov 23 at 7:56














  • 3




    Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
    – Andras Deak
    Nov 23 at 7:34






  • 1




    It does not give an error when I run just the program is crashing
    – Rarblack
    Nov 23 at 7:37










  • If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
    – Thierry Lathuille
    Nov 23 at 7:56








3




3




Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
– Andras Deak
Nov 23 at 7:34




Any chance you have non-printable characters in your code? Did you copy-paste any of it from the web?
– Andras Deak
Nov 23 at 7:34




1




1




It does not give an error when I run just the program is crashing
– Rarblack
Nov 23 at 7:37




It does not give an error when I run just the program is crashing
– Rarblack
Nov 23 at 7:37












If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
– Thierry Lathuille
Nov 23 at 7:56




If you're entering your code in the REPL, which is probably what you mean by 'terminal', you need to enter an empty line at the end of each indented block before continuing with a non-indented line. This would have been clearer for us if you had included in your question the real, complete error message, which, for me, starts with File "<stdin>", line 4. Always include your complete error traceback in your future questions! For your question: don't try to run long scripts in the REPL, it's not really convenient for that. Or remember to include an empty line at the end of indented blocks.
– Thierry Lathuille
Nov 23 at 7:56












1 Answer
1






active

oldest

votes


















0














I ran your code locally and it gives none syntax error. But there is an issue in your code. If you are willing to see the white borders you should place the input() the end because when it is in the middle it stays there till enter is pressed and not read the rest of the code and when entered just run the rest but you are not able to see any white borders because it is too fast.



import turtle
import os

wn = turtle.Screen()
wn.bgcolor("black")
wn.title("Space Invaders")

delay = input("Delay") # this one is for delay

border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300,-300)
border_pen.pensize(3)
border_pen.pendown()
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()
input('Press enter to exit') # for exiting


Take a look at this I screened from my local machine.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I ran your code locally and it gives none syntax error. But there is an issue in your code. If you are willing to see the white borders you should place the input() the end because when it is in the middle it stays there till enter is pressed and not read the rest of the code and when entered just run the rest but you are not able to see any white borders because it is too fast.



    import turtle
    import os

    wn = turtle.Screen()
    wn.bgcolor("black")
    wn.title("Space Invaders")

    delay = input("Delay") # this one is for delay

    border_pen = turtle.Turtle()
    border_pen.speed(0)
    border_pen.color("white")
    border_pen.penup()
    border_pen.setposition(-300,-300)
    border_pen.pensize(3)
    border_pen.pendown()
    for side in range(4):
    border_pen.fd(600)
    border_pen.lt(90)
    border_pen.hideturtle()
    input('Press enter to exit') # for exiting


    Take a look at this I screened from my local machine.






    share|improve this answer




























      0














      I ran your code locally and it gives none syntax error. But there is an issue in your code. If you are willing to see the white borders you should place the input() the end because when it is in the middle it stays there till enter is pressed and not read the rest of the code and when entered just run the rest but you are not able to see any white borders because it is too fast.



      import turtle
      import os

      wn = turtle.Screen()
      wn.bgcolor("black")
      wn.title("Space Invaders")

      delay = input("Delay") # this one is for delay

      border_pen = turtle.Turtle()
      border_pen.speed(0)
      border_pen.color("white")
      border_pen.penup()
      border_pen.setposition(-300,-300)
      border_pen.pensize(3)
      border_pen.pendown()
      for side in range(4):
      border_pen.fd(600)
      border_pen.lt(90)
      border_pen.hideturtle()
      input('Press enter to exit') # for exiting


      Take a look at this I screened from my local machine.






      share|improve this answer


























        0












        0








        0






        I ran your code locally and it gives none syntax error. But there is an issue in your code. If you are willing to see the white borders you should place the input() the end because when it is in the middle it stays there till enter is pressed and not read the rest of the code and when entered just run the rest but you are not able to see any white borders because it is too fast.



        import turtle
        import os

        wn = turtle.Screen()
        wn.bgcolor("black")
        wn.title("Space Invaders")

        delay = input("Delay") # this one is for delay

        border_pen = turtle.Turtle()
        border_pen.speed(0)
        border_pen.color("white")
        border_pen.penup()
        border_pen.setposition(-300,-300)
        border_pen.pensize(3)
        border_pen.pendown()
        for side in range(4):
        border_pen.fd(600)
        border_pen.lt(90)
        border_pen.hideturtle()
        input('Press enter to exit') # for exiting


        Take a look at this I screened from my local machine.






        share|improve this answer














        I ran your code locally and it gives none syntax error. But there is an issue in your code. If you are willing to see the white borders you should place the input() the end because when it is in the middle it stays there till enter is pressed and not read the rest of the code and when entered just run the rest but you are not able to see any white borders because it is too fast.



        import turtle
        import os

        wn = turtle.Screen()
        wn.bgcolor("black")
        wn.title("Space Invaders")

        delay = input("Delay") # this one is for delay

        border_pen = turtle.Turtle()
        border_pen.speed(0)
        border_pen.color("white")
        border_pen.penup()
        border_pen.setposition(-300,-300)
        border_pen.pensize(3)
        border_pen.pendown()
        for side in range(4):
        border_pen.fd(600)
        border_pen.lt(90)
        border_pen.hideturtle()
        input('Press enter to exit') # for exiting


        Take a look at this I screened from my local machine.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 23 at 7:52

























        answered Nov 23 at 7:45









        Rarblack

        2,7163925




        2,7163925















            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks