reverse-string

How to reverse a string

Learn how to reverse a string in different programming languages.

PYTHON

str = "That Guy Code"
str = str[::-1]
print(str)

#Output : "edoC yuG tahT"

JAVA

String str = "That Guy Code";
str = new StringBuilder(str).reverse().toString();
System.out.println(str);

#Output : "edoC yuG tahT"

 

JavaScript

let str = "That Guy Code";
str = str.split("").reverse().join("");
console.log(str);

// Output : "edoC yuG tahT"

PHP

$str = "That Guy Code";
$str = strrev($str);

echo $str;

// Output : "edoC yuG tahT"

C

char str[] = "That Guy Code";
strrev(str); //requires <string.h>
printf("%s", str);

// Output : "edoC yuG tahT"

C++

string str = "That Guy Code";
reverse(str.begin(), str.end());
cout<<str;

// Output : "edoC yuG tahT"

Related Posts

Use Emoji's in Python
Use Emoji’s in Python

Did you know you can use Emoji's in Python? Learn how to!

remove-duplicate-elements-in-a-list-with-python
Remove duplicate elements in a list with Python

A simple and efficient way to remove duplicate elements from a list using...