Click here to Skip to main content
15,917,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PROBLEM STATEMENT
Today is Sagar's birthday. He got array of numbers as a gift by his father. His father told him that he has another gift if Sagar is able make largest number by concatenating the numbers and swapping the digits of numbers. Help Sagar to make largest number from the given numbers

Input:

First line contains number of testcases T Next line contain value of number of values in array N Followed by N space separated number

Output:

Output the answer.

SAMPLE INPUT
2
5
1 2 20 31 5
4
9 1 5 10

SAMPLE OUTPUT
5322110
95110



I DON'T WANT ANYONE TO SOLVE THIS PROBLEM. I ONLY WANT TO KNOW HOW TO TAKE THE INPUT IN THE SINGLE LINE AS IN ABOVE PROBLEM. PLEASE USE PYTHON TO ANSWER THE QUESTION AS I KNOW THAT ONLY

What I have tried:

x, y, z = [int(x) for x in input().split()]


I tried this but in this I realized that the user should could enter the value upto a certain limit(i.e. , equal to the number of variables defined
Posted
Updated 22-May-20 1:09am

You can't "force" the user to enter N numbers on a line - heck you can;t even force most users to type numbers correctly!

Instead, you read what he did input and check that against what you expect, or asked for. If it's right, you continue. If it's wrong, you tell him why and ask him to input the correct information. (This is called input validation, and it's important if you want anyone to use your app in the real world).

And by the way: DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
 
Share this answer
 
Comments
Member 14517556 30-Sep-19 2:55am    
Firstof all sorry for that capitalisation. I didn't knew that it is rude. I just used that to make it different from the code above
Member 14517556 30-Sep-19 2:58am    
it was a challenge that I was appearing for and the site has input in such a way only and they were not accepting another method of accepting input
You approach is very close to the success. Just use
Python
l = [int(i) for i in input().split()]

And the many numbers will be contained in the list l. Then you may individually access the items of the list, for instance:
Python
print(l[0])  # outputs the value of the first item of the list
See, for instance Python Lists[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900