Skip to content
Exercise · Strings · lesson 7 of 8

Exercise: reverse a string

Write a function func reverse(s string) string that returns the characters of the string s in reverse order.

  • reverse("hello") → "olleh"
  • reverse("Привет") → "тевирП"
  • reverse("Go, мир") → "рим ,oG"

Constraints: the string is non-empty, up to 100 characters; it may contain Cyrillic, accented Latin letters, digits, spaces and punctuation.

Do not add extra imports unless the task says so explicitly.

reverse.go — go
go · 6 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way