C++ vs Python3 (strings)
Imagine that you have a given string "s". Imagine you've been instructed to write a concise program that converts every letter of the string to a lowercase letter. Since Python is known for its concise programming, the instructions given to you could be completed via a single line of code ... s = s.lower() In C++, it's very easy to complete the instructions, but can it be JUST AS concise as Python? Take for example ... for (int x = 0; x < s.length(); x++) s[x] = tolower(s[x]); The example code is simple enough, but wouldn't you think that there would be a much simpler and faster way to do the above? I thought for sure that the following code would work in C++, but was wrong: s = tolower(s); I'm going to take a wild guess and assume that the difference in string-manipulation between these two languages has to do with iteration via mutable/immutable strings, or the opposite...? Why wouldn't the following C++ code work either?: for (auto x : s) x = tolower(x); If you can think of a way to complete the example instructions from above using C++, and make it JUST AS concise as Python's example-code, feel free to enlighten me on what I'm missing. Else, if it can't be done yet you know why it can't be done, also feel free to enlighten me as to why that is. Thanks!