“Cadena inversa en Python” Código de respuesta

Cómo revertir una cadena en Python

# in order to make a string reversed in python 
# you have to use the slicing as following

string = "racecar"
print(string[::-1])
Tejas Naik

Cómo imprimir una entrada al revés en Python

str="Python" # initial string
stringlength=len(str) # calculate length of the list
slicedString=str[stringlength::-1] # slicing 
print (slicedString) # print the reversed string
Wandering Wolf

Cadena inversa en Python

'hello world'[::-1]
'dlrow olleh'
Kind Kangaroo

Python revertir una cadena

# Slice notation takes the form [start:stop:step]. In this case, 
# we omit the start and stop positions since we want the whole string. 
# We also use step = -1, which means, "repeatedly step from right to left by 
# 1 character".

'hello world'[::-1]

# result: 'dlrow olleh'
Terrible Toad

Cómo imprimir una cadena por reverso en Python

s = "001100"
for x in s[len(s)-1::-1]:
    print(x)
Excited Earthworm

Cadena inversa en Python

txt = "Hello World"[::-1]

print(txt)
Coding boy Hasya

Respuestas similares a “Cadena inversa en Python”

Preguntas similares a “Cadena inversa en Python”

Más respuestas relacionadas con “Cadena inversa en Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código