I am having trouble understanding the meaning of the following code:
begin = None
while begin != "":
begin = (raw_input("\nBegin:"))
What does begin !="" mean? What does the empty string "" represent?
What does begin !="" means?
It means begin does not refer to an empty string -- it's satisfied at the start (as begin refers to None, not to an empty string) and will stay satisfied as long as the user types anything else than just a <return>.
What does the empty string "" represent??
It represents what raw_input returns when the user just hits the <return> (AKA <enter>) key without actually typing anything at the prompt.
"" represents an empty string. So begin != "" is true whenever begin doesn't contain an empty string. The initial value None is not an empty string, so the loop will run at least once. After that, begin will contain whatever the user entered in response to the Begin: prompt. If he enters nothing (i.e. just presses Return) it will be an empty string, the test will fail, and the loop will end.
Returnin response to the prompt, it will be set to the empty string.while not begin:to test for the empty string