Skip to content

Latest commit

 

History

History
55 lines (32 loc) · 826 Bytes

Are_the_numbers_in_order.md

File metadata and controls

55 lines (32 loc) · 826 Bytes

CodeWars Python Solutions


Are the numbers in order?

Given a string, you need to write a method that order every letter in this string in ascending order.

Also, you should validate that the given string is not empty or null. If so, the method should return:

"Invalid String!"

Notes

  • the given string can be lowercase and uppercase.
  • the string could include spaces or other special characters like '# ! or ,'

Examples

"hello world" => " dehllloorw"
"bobby"       => "bbboy"
""            => "Invalid String!"
"!Hi You!"    => " !!HYiou"

Given Code

def in_asc_order(arr):
    pass

Solution

def in_asc_order(arr):
    return arr == sorted(arr)

See on CodeWars.com