Python Forum

Full Version: Some Code For a program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
# INPUT WORD & CHARACTER LENGTH VARIABLES
x = input("Insert Any Word: ")
y = len(x)
# .FORMAT VARIABLES
numPrompt = "Number Of Characters: "
clean = "Backwards Spelling of word: "
clean2 = "This word is a palendrome."
# PRINTS NUMBER OF CHARACTERS
print("Number of characters: {0}".format(y))
txt = "{0}".format(clean) +x[::-1]
# PRINTS BACKWARDS VALUE OF X
print(txt)
# PALENDROME STATUS
if x in txt:
  pal1 = "Palendrome: No"
  pal2 = "Palendrome: Yes"
  pal3 = "Palendrome: Unknown"
  print()
  print("Palendrome: Yes")
else:
  print()
  print("{0}".format(pal1))
# ERROR CHECKER
if (y==[]):
  error = "ERROR!"
  print(error)
# GLOBAL VARIABLES
global error
global pal1
global pal2
global pal3
Do you have a problem with the code that you need help with?
Is something like this what you're looking for?

# INPUT WORD
x = input ("Insert Any Word : ")

# PRINTS NUMBER OF CHARACTERS
print(f"Number of characters: {len (x)}")

# PRINTS BACKWARDS VALUE OF X
b = x [::-1]
print (f"Backwards its' : {b}.")

# PALENDROME STATUS
if b == x : p = 'is'
else : p = 'is not'
print (f"This word {p} a palendrome.")