Files
30-seconds-of-code/snippets/reverse.md
Isabelle Viktoria Maciohsek 98b5f67412 Update snippet descriptions
2020-11-02 19:28:27 +02:00

256 B

title, tags
title tags
reverse list,string,beginner

Reverses a list or a string.

  • Use slice notation to reverse the list or string.
def reverse(itr):
  return itr[::-1]
reverse([1, 2, 3]) # [3, 2, 1] 
reverse('snippet') # 'teppins'