#Python #Rust #rustlang #programming #textprocessing
Learn how to swap uppercase and lowercase and text within a string using Python and Rust as example languages. This no-fluff tutorial is excellent for those people who like to learn by doing.
It's not the most efficient way to do this though. What are your suggested improvements?
Python code as a single function:
def invert_case(text: str):
opposites = {}
for (u, l) in zip(iter(text.upper()), iter(text.lower())):
opposites[u] = l
opposites[l] = u
return "".join(opposites[c] for c in iter(text))
Rust code available via this link: play.rust-lang...
📚 Resources:
Code: github.com/tim...
👋 Connect with Tim
www.youtube.co...
/ timmcnamaranz
/ timclicks
github.com/tim...
mastodon.nz/@t...
dev.to/timclicks/
/ timclicks
🔔 Subscribe to the channel and click the bell icon to stay updated with the latest videos and live streams from timClicks: www.youtube.co...
👍 Like this video if you found it helpful, and share it with your friends who are also interested in Rust programming.
13 сен 2024