Repeat bang
-
I'm writing a converter in a drab, and the interpreter somehow turns the drabs off as many times as the length of the line I'm introducing, but I need a line of the length of the line I'm introducing. How do you fix the repetition?
if mode in ("Fraction", "fraction", "frc", "Frc", "fr", "Fr"): pass elif mode in ("Integer", "int", "Int", "integer"): den = input ("Choose the denominators: [10, 100, 1000, 10000, 100000, 1000000, 10000000, 50, 500, 5000, 20, 200, 2000]\n") if den in ("10", "100", "1000", "10000", "100000", "1000000", "10000000", "50", "500", "5000", "20", "200", "2000"): numbDen = int (den) human = input ("What number?\n") for letter in human: if letter in ('1', '2', '3', '4', '5', '6', '7', '8', '9', '0'): intHuman = int (human) numerator = intHuman * numbDen strNumerator = str(numerator) print (numerator) dash = '_' * len (strNumerator) print (dash) print (numbDen) else: raise SyntaxError ("Uncorrect number") else: raise SyntaxError ("Can't recognize this denominators") elif mode in ("Float", "float", "flt", "Flt", "fl", "Fl"): pass else: raise TypeError ("Invalid mode")
That's what he's doing. [Fraction/Integer/Integer with Float?] int Choose the denominators: [10, 100, 1000, 10000, 100000, 1000000, 10000000] 1000000 What number? 439 439000000
1000000 439000000
1000000 439000000
1000000
-
What do you want if you have a cycle to analyse the numbers of the assigned number?
for letter in human:
And for each digit, you're forming three lines of withdrawal of the drab
You know how many numbers you've got, as many asjacks, and you'll be out.
In fact, the code is very inefficient - very much extra.