Python Forum
Some Code For a program - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Some Code For a program (/thread-33312.html)



Some Code For a program - PythonCodeMaker_119 - Apr-14-2021

# 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



RE: Some Code For a program - Yoriz - Apr-14-2021

Do you have a problem with the code that you need help with?


RE: Some Code For a program - BashBedlam - Apr-14-2021

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.")