Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
One-liner solution in Creative category for Ascending List by Safwan_Samsudeen
#
#
#
#
#
from typing import Iterable
def is_ascending(items: Iterable[int]) -> bool:
return sorted(items) == items and len(set(items)) == len(items)
def test():
assert is_ascending([-5, 10, 99, 123456]) is True
assert is_ascending([99]) is True
assert is_ascending([4, 5, 6, 7, 3, 7, 9]) is False
assert is_ascending([]) is True
assert is_ascending([1, 1, 1, 1]) is False
if __name__ == '__main__':
print("Example:")
print(is_ascending([-5, 10, 99, 123456]))
test()
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 13, 2020
Comments: