ejemplos=[('Alegan','Ángela'), ('Nepal','Panel'), ('Nacionalista','Altisonancia'), ('Valora','Álvaro'), ('Raza','Zara'), ('Frase','Fresa'), ('Colinas','Nicolás'), ('Pagar','Praga'), ('Integrarla','Inglaterra'), ('Quieren','Enrique'), ('Cornisa','Narciso'), ('Acuerdo','Ecuador'), ('fotolitográficamente','litofotográficamente')]
salir =False
while salir is False:
string_1=""
string_2=""
print("seleccione:\n\tIngrese dos strings y verifique si son anagramas\n\tS) salir")
string_1=input("Ingrese la primer palabra:").upper()
string_2=input("Ingrese la segunda palabra:").upper()
if string_1=="S" or string_2=="S":
print("Adios")
salir = True
elif len(string_1)!=len(string_2):
print ("Error en el ingreso, no miden lo mismo")
continue
else:
print("*"*50)
print (f"Entrada: {string_1} y {string_2}")
palabra1 = palabra1.lower()
palabra2 = palabra2.lower()#····················· Pasar a minúsculas el string_1 y string_2
#····················· Reemplaza las vocales con acento por sin acento del string_1 y string_2
print (f"Salida : {string_1} y {string_2}")
#····················· convertir el string_1 en lista_1 y string_2 en lista_2
#····················· ordenar alfabéticamente lista_1 y lista_2
print (f"listas de caracteres ordenados, sin acentos y en minúsculas \n{lista_1=}\n\t\ty\n{lista_2=}")
if lista_1==lista_2:
print (f"{string_1} y {string_2} son anagramas")
else:
print (f"{string_1} y {string_2} No son anagramas")
print("*"*50)
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
You need to fix this error:
NameError: name 'palabra1' is not defined
You have a variable string1
but no variable palabra1
print (f"Entrada: {string_1} y {string_2}")
palabra1 = palabra1.lower()
palabra2 = palabra2.lower()