Python Forum
create three digit numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create three digit numbers
#1
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
Reply
#2
What have you tried? Shouldn't this be in the 'homework' section?
Reply
#3
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
Reply
#4
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') 
Reply
#5
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Generator: From Word to Numbers, from Numbers to n possibles Words Yamiyozx 2 1,370 Jan-02-2023, 05:08 PM
Last Post: deanhystad
  list digit into number Voldyy 2 1,496 Jul-10-2022, 06:13 PM
Last Post: deanhystad
  Convert list of numbers to string of numbers kam_uk 5 2,936 Nov-21-2020, 03:10 PM
Last Post: deanhystad
  Frequency in first digit from csv file, NO IMPORT bryan0901 6 2,787 May-28-2020, 09:50 AM
Last Post: bryan0901
  Four-digit number text translation. soz 3 2,651 May-13-2019, 03:02 PM
Last Post: buran
  Turning column of 8 digit numbers into three seperate columns Wade334 1 2,148 May-11-2019, 02:52 PM
Last Post: Larz60+
  Sum of digit in a string MEH012 1 9,334 Apr-20-2018, 02:13 AM
Last Post: Larz60+
  Regular Expressions in Files (find all phone numbers and credit card numbers) Amirsalar 2 4,056 Dec-05-2017, 09:48 AM
Last Post: DeaD_EyE
  Allow only digit penoxcz 3 3,750 Nov-14-2017, 03:04 PM
Last Post: wavic
  Four digit combinations EHod 4 7,704 Aug-13-2017, 09:14 PM
Last Post: EHod

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020