Published: 12 Aug 2023 › Updated: 12 Aug 2023
Codewars Kata - Testing 1-2-3
DESCRIPTION:
Your team is writing a fancy new text editor and you've been tasked with implementing the line numbering.
Write a function which takes a list of strings and returns each line prepended by the correct number.
The numbering starts at 1. The format is n: string. Notice the colon and space in between.
Examples: (Input --> Output)
[] --> []
["a", "b", "c"] --> ["1: a", "2: b", "3: c"]
def number( lines ):
return [ f"{ i + 1 }: {lines[i]}" for i in range( len( lines ) ) ]
Leave Codewars Kata - Testing 1-2-3 to:
Read more #programming posts
Best Posts From Lochard
We have not curated any of lochard's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Lochard
- King's Cross - 45th month of persecution by CCP, LT &UK
- 43rd month, belongings stolen
- Another round of strong damage
- 41st month of humiliation, torture and other crimes
- This is not a prank
- How sick one has to be to take pleasure in drugging and indirectly molesting others?
- Has AI already surpassed humans in morality and emotion?
- Just a reminder that your fellow biped had been treated as non-human for 39 months
- Psychopathy (Chat with AI)
- [Solved] Oracle Linux 10 WiFi adpator not found