3 129 Python mmnow 2018-11-20 15:56:16
click to edit code
W przypadku złej wartości wyrzuca wyjątek, adnotacje dla sugestii poprawnych typów
                        import random
import string

charset = string.ascii_letters + string.digits + string.punctuation

def gen(length: int) -> str:
  if not 8 <= length <= 256: raise Exception(f"Wrong length: {length}")
  return ''.join([random.choice(charset) for i in range(0, length)])