numbers = ["1", "2", "3", "4a", "5"] numbers2 = [] for text in numbers: try: number = int(text) except ValueError as e: print("Pozor! Data obsahuji neciselnou hodnotu {}".format(text)) number = 0 numbers2.append(number) print numbers2