Skip to main content

Posts

Inputs and Outputs in Python 3

Recently, I was training on some libraries in Python 3 and I noticed that the most difficult was not the questions, but the way you are going to take your input and present your output.  So, I'd like to show some ways I've learned and it may help you, too.  1. Lists:  Taking separated input like:  2 3 4 5 6 7 and put them into the list can be done by map function:  a = list (map(int, input().split())) or  a = tuple(map(int, input().split())) same if inputs are float - I will say that you don't need to do the same if the inputs were string! because the string is easily added into a list like:  a = input().split() < it put them directly into a list>  ___________________________ If you'll take 2 separated numbers and you are going to use just one of them, so:  you may use one of those ways:  n, m = list(map(int, input().split()) ) and use them by their names n, m, and so on.  or you can use:  p = input().split() them if yo...