# Initial setting of the variable and of the next integer up. x = 999.5 x_next = x + 1 # x is made a string. yahoo! x = str(x) # here is where we find the position of the decimal decimal_loc = x.find('.') # here we convert the possible round up number into a string and find it's length. x_next = str(x_next) x_next_decimal_loc = x_next.find('.') print x_next_decimal_loc x_next_length = x_next_decimal_loc # Here we convert both of these numbers into their base integer form. x_base_decimal_loc = x.find('.') x_base = x[:decimal_loc] print x_base_decimal_loc x_base_length = x_base_decimal_loc x_next = x_next[:x_next_decimal_loc] print x_next # here we find the tenth digit. It's very important. tenth = x[decimal_loc + 1] print tenth # The number bank that we use to sort numbers. Perhaps this can be more flexible by way of variable length. number_bank = '0123456789' # The number location might also include variable lengths. number_loc = number_bank.find(tenth) print number_loc # The x bank is our core design feature. I have trouble seeing it changing much. # Maybe the 5's could be variables. x_bank = x_base * 5 + x_next * 5 print x_bank print 'x_base_length is ' print x_base_length print 'x_next_length is ' print x_next_length # Here we have found the first occurence and second occurence of x_next. We also have a length variable. # Its length might not be correct. # Here we find a solution. print x_bank[number_loc]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question