-5

I have written the following program and it works as expected however I would like the user to input something This is my code:

from fractions import Fraction
from math import log10

def maxnum(x):
    return ''.join(str(n) for n in sorted(x, reverse=True,
                          key=lambda i: Fraction(i, 10**(int(log10(i))+1)-1)))

for numbers in [(1, 34, 3, 98, 9, 76, 45, 4), (54, 546, 548, 60)]:
    print('Numbers: %r\n  Largest integer: %15s' % (numbers, maxnum(numbers)))

I would like it to print out "enter the numbers" user inputs the numbers he would like to concatenate into a larger number and then the program outputs it in the same way as the code above. How do I do that Thanks in advance

  • 1
    [`input`](https://docs.python.org/3/library/functions.html#input) is the function you're looking for – Patrick Haugh Nov 06 '17 at 15:14
  • This has been discussed in depth in [this stackoverflow question](https://stackoverflow.com/questions/70797/python-user-input-and-commandline-arguments) – suripoori Nov 06 '17 at 15:17
  • What I would like to do is replace (1, 34, 3, 98, 9, 76, 45, 4), (54, 546, 548, 60 with what the user entered – Andreas Kruger Nov 06 '17 at 15:30
  • Then there's also another answer for you https://stackoverflow.com/q/4663306/6622817 – Taku Nov 06 '17 at 15:49

1 Answers1

-1

Try following a tutorial like http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/io.html

person = input('Enter your name: ')
print('Hello', person)
Hector
  • 1,170
  • 2
  • 10
  • 27