How can I merge these two lines of code into one (Python 3.X)?
text = ''.join(sorted([x for x in input()])) text = text.replace('+', '', text.count('+')) I just it love it when you can do all sort of things in one line with Python.
text = ''.join(sorted(input())).replace('+', '') OR text = ''.join(sorted(input().replace('+', ''))) You don't need to use list comprehension. Just pass the input() to sorted(); sorted support any iterable. the 3rd argument to str.replace() is redundant. Because the code is replacing all occurences of +.
Ok, this is not exactly the same code, but in this case result is similar: text = ''.join(sorted([x for x in input() if x != '+'])) Instead of creating whole string and then replacing one character, you can simply remove it in first list comperhesion.
Recursive function with one argument that does something to each element
Storing and Graphing results of API queried via Python. [on hold]
While handling Exceptions, how to print any error statement that occurs? See below for more details
Having trouble getting my calculator app to print the result I want
Why am I getting this ValueError?
How to recognize single digit in string to insert leading zero?
How can I configure a test environment with Falcon
Computing the gradient for a custom TensorFlow op with py_func()
get all files in drive via REST API
Setting an image as a tkinter window background
Displaying A File Using StringVar() // Tkinter Python 3.5
How are features ranked in RFECV in scikit learn(sklearn)?
Solr requests hang when started via python subprocess
How to extract internet email headers from outlook emails?
Tensorboard get blank page
Python Matplotlib Streamplot providing start points