Hey anyone know why I keep getting an error saying invalid escape sequence

Joined
Jul 25, 2024
Messages
13
Reaction score
1
import math
import random
import time
import datetime as dt
EggBinar = ['''
______
/ \
/ \
/ | | \
| | |
| __ _|
\ / \ /
\ / \ /
/|\ /|\ ''']
print("Welcome to the world of CCmon please be patient \n\n before you can enter this world we need a little information \n\n to make the right character for this world")
UserName = input("What is your name?: ")
UserGender = input("Are you Male or Female: ")
print("Welcome ", UserName, " to the world of CCmon My name is Proffesor Albert Iggyness or Prof AI for short.")
print("This world is inhabited by computer made monsters that were brought to life using ancient technology")
print("These Monsters are the subject of my Research but instead of just telling you let me show you one")
print(EggBinar(len(0)))
print("That my friend is a CCmon known as EggBinar")
 
Joined
Jul 25, 2024
Messages
13
Reaction score
1
The Pic i am trying create using the list named EggBinar is a bit off because of this site
 
Joined
Sep 21, 2022
Messages
148
Reaction score
21
A backslash inside a string is one character, but is written as two, in a program's source code.

If you replace \ with \\ in your source, it should work on screen, but your image will look like a mess in your code.

I suggest using another character in your source, then have the program replace it with \ before printing.

The screen will look correct, and the source code will be similar to the screen.
 
Joined
Jul 4, 2023
Messages
453
Reaction score
54
  • Fixed the way of accessing the ASCII art (EggBinar[0] instead of EggBinar(len(0))).
  • Added raw strings (r''') formatting for strings, making the code cleaner.

Python:
import math
import random
import time
import datetime as dt

EggBinar = [r'''
  ______
  /    \
 /      \
/  |  |  \
|        |
|   __   |
\        /
 \      /
  \    /
 /|\  /|\
''']

print("Welcome to the world of CCmon! Please be patient.\n")
print("Before you can enter this world, we need a little information\n")
print("to make the right character for this world.")
UserName = input("What is your name?: ")
UserGender = input("Are you Male or Female?: ")

print(f"Welcome, {UserName}, to the world of CCmon! My name is Professor Albert Iggyness, or Prof AI for short.")
print("This world is inhabited by computer-made monsters that were brought to life using ancient technology.")
print("These Monsters are the subject of my research, but instead of just telling you, let me show you one.")

print(EggBinar[0])

print("That, my friend, is a CCmon known as EggBinar.")

Python:
EggBinar = r'''
  ______
  /    \
 /      \
/  |  |  \
|        |
|   __   |
\        /
 \      /
  \    /
 /|\  /|\
'''

print(EggBinar)
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,879
Messages
2,569,939
Members
46,232
Latest member
DeniseMcVi

Latest Threads

Top