CODE CHALLENGE - REVERSE WORDS IN A STRING | Python Programming for Beginners
💻 Code along with a Python 3 online compiler: https://www.onlinegdb.com/online_python_compiler
⭐ SUBSCRIBE to Apptato for more Brain Teasers, Code Challenges and interesting math problems!
Question:
Reverse a String
For example:
- 1 2 3 4 5 -- 5 4 3 2 1
- Reverse a String in Python 3 -- 3 Python in String a Reverse
Coverage & Review:
Array Split
Array Join
Array For Loop
Answer:
Code:
string = "5 4 3 2 1"
def reverseString(s):
wordArray = s.split(' ')
output = []
for word in wordArray:
output.insert(0,word)
return " ".join(output)
print(reverseString(string))
Thanks for watching
Until next time!
*** LINKS ***
Website: http://www.apptato.com
YouTube: https://www.youtube.com/apptato
Twitter: https://www.twitter.com/apptato
Facebook: https://www.facebook.com/apptato
Instagram: https://www.instagram.com/apptato
#CODE #PYTHON #PROGRAMMING
reverse words in a string python,reverse words in a string,reverse string python,python,python programming tutorial,python programming,reverse words in a given string python,reverse words in a given string,coding challenge,algorithm,coding,code,code challenge,reverse string,array,challenge,string,reverse,split,join,python basics,python tutorial,python strings,python tutorial for kids,python tutorial for beginners