Bottom Page

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
Quote
#2
What have you tried? Shouldn't this be in the 'homework' section?
micseydel likes this post
Quote
#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
Quote
#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') 
Gribouillis likes this post
Quote
#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)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  integer representing a 10-digit phone number critter70 5 103 May-17-2019, 09:29 AM
Last Post: saravanatn
  Four-digit number text translation. soz 3 79 May-13-2019, 03:02 PM
Last Post: buran
  Turning column of 8 digit numbers into three seperate columns Wade334 1 87 May-11-2019, 02:52 PM
Last Post: Larz60+
  Sum of digit in a string MEH012 1 1,433 Apr-20-2018, 02:13 AM
Last Post: Larz60+
  Regular Expressions in Files (find all phone numbers and credit card numbers) Amirsalar 2 1,086 Dec-05-2017, 09:48 AM
Last Post: DeaD_EyE
  Allow only digit penoxcz 3 1,069 Nov-14-2017, 03:04 PM
Last Post: wavic
  Four digit combinations EHod 4 1,568 Aug-13-2017, 09:14 PM
Last Post: EHod
  create a 20 digit string, and cast to a list then add all the digits as integers nikhilkumar 2 1,402 Jul-19-2017, 04:53 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)