Attempt this one with python code | Sololearn: Learn to code for FREE!

+2

Attempt this one with python code

Problem Statement: Need to process an input string, accepted from STDIN. and find only all the numeric tokens that are present in the string. Consider tokens to be sequence of printable characters separated by space(s). (In numeric tokens all characters are digits) You need to build a new string which is of the form numeric_token1 numeric_token2 print this in ascending order. (A single space is the separator) (If no numeric tokens are found you need to print NONE FOUND) Input : We need to read a line from STDIN to extract the numeric tokens only Output : The string composed of number1 number2 in ascending order . Or NONE FOUND Test Cases: Input: hello hi 123 789 45 hi Output: 45 123 789 Input: 20 abc beg 90 67 Output: 20 67 90 Input: hi hello foo bar foo Output: NONE FOUND My attempt in python language https://code.sololearn.com/c46CVAEThQzk/?ref=app

9/28/2021 4:58:18 AM

Màñøj

9 Answers

New Answer

+3

Hi Manoj link for challenges attached https://www.sololearn.com/Discuss/1270852/?ref=app

+3

https://code.sololearn.com/caoO4y8I1VMY/?ref=app

+2

Your code is working fine , but you have to include the header "stdio.h" before using printf() function

+2

https://code.sololearn.com/c6LVdWFwT0I3/?ref=app

+1

Hi Manoj Interesting challenge but posted in the wrong place. Q&A is for coding related questions only, not challenges. The best place to post a challenges is in your personal feed, or on a post which I will link here for you.

+1

Python solution txt = input() li = txt.split(" ") nli = [] for pos, i in enumerate(li): if i.isdigit(): nli.append(i) nli.sort() out = "" if len(nli) == 0: print("Not found") else: for i in nli: if pos != len(nli) - 1: out += i +" " else: out += i print(out)

+1

Welcome to the Challenge section. Have a look at the previous challenges to see the format. Somehow you have managed to post your entire Q&A here, not to worry. My attempt attached https://code.sololearn.com/c4rRVEUB834Y/?ref=app

+1

text = list(input().split()) lstNumber=[] for i in text: if i.isdigit(): lstNumber.append(int(i)) if len(lstNumber)!=0: lstNumber.sort() for i in lstNumber: print(i,end=' ') else: print ('not found')

0

For this I/p - fac tsh sh ish It's not working