Monday, November 23
Trending
- AI-Powered Cyberattacks in 2026: How Hackers Use AI Agents
- US Outages Explained: What Happened to Microsoft, FAA and Banks
- Microsoft 365 Outage: Outlook, Teams and Copilot Down. What We Know
- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
Reverse words order and swap cases using Python
Input: Hello World
Output:wORLD hELLO
The function is expected to return a STRING
The function accepts STRING sentence as a parameter.
def reverse_words_order_and_swap_cases(sentence):
mystr = ''
for i in sentence:
if i.isspace():
mystr+= " "
else:
if i.isupper():
mystr+= i.lower()
if i.islower():
mystr+= i.upper()
words = list(reversed(mystr.split()))
mywords = " ".join(words)
return mywords
out = reverse_words_order_and_swap_cases("Hello World")
print(out)In above program:
isupper() method is used to check the given letter is capital or not.
islower() method is used to check the given letter is small or not.
lower() method is used to convert string or character to small.
upper() method is used to convert string or character to capital.
The reversed() function returns an iterator that accesses the given sequence in the reverse order.



