Python - nesesito alluda con este ejersisio

 
Vista:

nesesito alluda con este ejersisio

Publicado por wyatt (1 intervención) el 08/10/2020 00:49:59
python supuestamente deveria revisar si las dos primeras letras son identicas i asi arojar si es verdadero o falso

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def is_palindrome(input_string):
	# We'll create two strings, to compare them
	new_string = "never odd or even","kayak"
	reverse_string = "never odd or even", "kayak"
	# Traverse through each letter of the input string
	for new_string in reverse_string:
		new_string = str(new_string[0], str(new_string[-1]))
		reverse_string = str(reverse_string[0], str(reverse_string[-1]))
		# Add any non-blank letters to the
		# end of one string, and to the front
		# of the other stri
	# Compare the strings
	if new_string == reverse_string:
		new_string = reverse_string
		reverse_string = new_string
		return True
	return False
 
print(is_palindrome("Never Odd or Even")) # Should be True
print(is_palindrome("abc")) # Should be False
print(is_palindrome("kayak")) # Should be True



Error on line 19:
print(is_palindrome("Never Odd or Even")) # Should be True
Error on line 7:
new_string = str(new_string[0], str(new_string[-1]))
TypeError: decoding str is not supported
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder