“Cara membalikkan string di python” Kode Jawaban

membalikkan string di golang

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}
Frantic Finch

cara membalikkan string di 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

cara membalikkan string di python

string = "string"
rev = "".join([l for l in reversed(string)])
RobynoDude

cara membalikkan string di python

user_input = input("Input the sentence you want reversed: ")
print (user_input[::-1])
#This is the easiest way to do it lol
A Dude

cara membalikkan string di python

belief = "the world is mine, hello"[::-1]
print(belief)
Important Ibis

Cara membalikkan string di python

print("hello world"[::-1])
'dlrow olleh'
Oluwayanmi Stephen

Jawaban yang mirip dengan “Cara membalikkan string di python”

Pertanyaan yang mirip dengan “Cara membalikkan string di python”

Lebih banyak jawaban terkait untuk “Cara membalikkan string di python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya