Token error: EOF in multiline expression in Python ... what does this mean?

I am just starting to learn how to code and I am learning with Python. I am trying to write a program that will print ASCII art every time the user types 1, but when I try to run the module, it gives me a title error.

here is my code: Where did I go wrong?

yORn = int(input("Type 1 to run the program, Type 2 to Exit:  ")
while yORn = 1:
   Name = str(input("What is your name?"))
   print("      1111111111111111111111     ")
   print("      1                    1     ")
   print("      1                    1     ")
   print("      1   Hello...         1     ")
   print("      1        ", Name,"   1     ")
   print("      1                    1     ")
   print("      1                    1     ")
   print("      1111111111111111111111___  ")
   print("             11111111          | ")
   print("     ------------------------- O ")
   print("    1.............._... ... 1    ")
   print("   1...................... 1     ")
   print("  -------------------------      ")
   yORn = int(input("Type 1 to run the program, Type 2 to Exit:  ")
print ("GoodBye")

      

+3


source to share


2 answers


You have an immediate answer (missing parentheses), but if you do things like this, I would suggest a different approach and use multi-line strings using (using triple quotes) and string formatting:

ascii_art = """
    1111111111111111111111     
    1                    1     
    1                    1     
    1   Hello...         1     
    1{name:^20}1     
    1                    1     
    1                    1     
    1111111111111111111111___  
           11111111          | 
   ------------------------- O 
   .............._... ... 1    
 1...................... 1     
-------------------------          
"""

print ascii_art.format(name='Kevin')

      

{name:^20}

takes a parameter name

and centers it within 20 characters ^20

so that it fits well into the block (computer monitor?) ....



Output example:

    1111111111111111111111     
    1                    1     
    1                    1     
    1   Hello...         1     
    1       Kevin        1     
    1                    1     
    1                    1     
    1111111111111111111111___  
           11111111          | 
   ------------------------- O 
   .............._... ... 1    
 1...................... 1     
-------------------------  

      

+7


source


You forgot to close the parenthesis in two places:

yORn = int(input("Type 1 to run the program, Type 2 to Exit:  ")) # < 2 closing parenthesis here

      

And again at the end of your code.



Note that your operator while

also has a bug; =

is the assignment, you meant ==

instead:

while yORn == 1:

      

+6


source







All Articles