create three digit numbers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: create three digit numbers (/thread-14613.html) |
create 3 digit numbers - Krszt - Dec-08-2018 Hello! I would like to get all the 3 digit numbers where, the digit on the right side is equal or bigger than the previos one (on its left). Like: 112, 122,123 are okay but 132 is not good. Could you give some hint to get all the combinations? Thank you RE: create 3 digit numbers - Gribouillis - Dec-08-2018 What have you tried? Shouldn't this be in the 'homework' section? create three digit numbers - Krszt - Dec-09-2018 Hello! I would like to get all the 3 digit numbers where, the digit on the right side is equal or bigger than the previos one (on its left). Like: 112, 122,123 are okay but 132 is not good. Could you give some hint to get all the combinations? Thank you RE: create three digit numbers - Axel_Erfurt - Dec-09-2018 create a digit numbers list and ask for mydigits = [112, 122, 123] the_digit = input('Enter Digit:\n') if int(the_digit) in mydigits: print('Digit OK') else: print('Digit not OK') RE: create three digit numbers - ThePhi - Dec-09-2018 like this?: result = [] for nb in range(100,1000): nb_str = str(nb) if int(nb_str[0]) <= int(nb_str[1]) and int(nb_str[1]) <= int(nb_str[2]): result.append(nb) print(result) |