This is because Python is a functional programming language and relies on indenting to determine where statements belong.
in C# and C++, it doesn’t care about indenting or if statements are on the same line. Other programming languages such as Fortran, Pascal and Visual Basic to name a few offer some kind of begin and end to a statement for scope
So, you can do the following in C++/C#
if (statement is true) do a;do b;
while (statement is true) do c; do d;
a will only be done if the statement is true, b will always be done.
Same with the while - while true, c will be executed and d will be executed on finishing the loop
It is good practice to not put everything on one line and always use { } in your statements like if, for and while loops which will prevent issues like in the above example.
again, rather than do
if (statement is true) { do a;do b; }
which is actually perfectly valid, do this:
if (statement is true)
{
do a;
do b;
}
This is far easier to read and debug, easier to add extra statements and less error prone.
These all apply to both C# and C++.
EDIT: In fact, thinking about it, all c-style languages such as JavaScript as well as Java follow the same rules.