What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-27 01:50:04
how to reverse word order in python
## initializing the string string = "I am a python programmer" ## splitting the string on space words = string.split() ## reversing the words using reversed() function words = list(reversed(words)) ## joining the words and printing print(" ... Add solution -
Python 2022-02-06 14:00:27
python string in set
a_string = 'Hello World Hello' # In case we want to get a 'set' of chars print(set(a_string)) # Output -> {'W', 'r', 'l', 'H', 'd', ' ', 'o', 'e'} # In case we want to get a 'set' of words print(set(a_string.split())) # Output -> {'Hello', 'World'} Add solution -
Python 2022-01-22 04:00:52
python string remove whitespace and newlines
' '.join(myString.split()) Add solution -
Python 2021-11-13 02:00:12
reolace double space ti single space in python'
' '.join(mystring.split()) Add solution -
Python 2021-10-31 01:35:10
capitalize python
# Python string capitalization string = "this isn't a #Standard Sntence." string.capitalize() # "This isn't a #standard sentence." string.upper() # "THIS ISN'T A #STANDARD SENTENCE." string.lower() # "this isn't a #stand... Add solution -
Python 2021-10-10 04:48:10
capitalize string python
# Python string capitalization string = "this isn't a #Standard Sntence." string.capitalize() # "This isn't a #standard sentence." string.upper() # "THIS ISN'T A #STANDARD SENTENCE." string.lower() # "this isn't a #stand... Add solution -
Python 2021-09-28 03:06:03
python split input to list
input_string = input('Enter elements of a list separated by space ') print("\n") user_list = input_string.split() # print list print('list: ', user_list) # convert each item to int type for i in range(len(user_list)): # convert each item to... Add solution -
Python 2021-09-13 12:54:01
replace multiple spaces with single space python
' '.join(mystring.split()) Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5