Python syntax error with "else" - syntax

I am using IDLE and Python 2.7. I am new to python and programming in general so sorry if this is extremely newbish, which it probably is.
Anyway, I'm following along and taking notes with python video and I was using IDLE and I keep getting this syntax error http://i.imgur.com/9urr4IW.png . I tried moving "else:" back to see if that was the problem but that didn't help. Just giving me a hint would help lol, thanks.

White space is significant in loops and if-else in python, I believe you wanted something like
if sister_age > brother_age:
print("Sister is older")
else:
print("Brother is older")

I solve your problem and solution is very simple...you just have to start the else part from the start of IDLE like i have done you will get your desirable output .

Related

I may sound very dump lol - but getting everything straight in the first place is better than not to ask at all

Beginner with python - I am taking a class with data camp and in one exercise, I used " # " to add my comment, after running the code, the comment is not showing up I believe it should right.
Did I miss anything or is the exercise screen has a bug or something? This question is too simple, I may sound dump but rather focus on learning the basics before moving on. lol.
If your line starts with the comment sign #, then the python interpreter will ignore this line.
So if you run these lines:
print("Hello earth")
# print("Hello moon")
The output will be only Hello earth

How to get started posting a question with Stack Overflow?

I know this is going to sound extremely stupid but I honestly cannot figure out how to post a question I have here for a program I am trying to make.
Whenever I paste my code into the code section this website tells me I have not formatted correctly. I triple check everything and it is all perfectly formatted. It is strange though because my code ends up being halfway into the place where I am suppose to describe the issue. So I am definitely doing this wrong.
Would somebody please walk me through a simple tutorial so I can finally ask my questions?
Honor to help you, I think you can first learn how to use markdown.
And this is two useful tutorial I read when I am learning.
Perfect question : WRITING THE PERFECT QUESTION
Use Markdown effectively : Markdown Getting Started
As for the display of code you mention above, you can use triple ``` to surround the code like this
import math
print('hello world')

Is there any exp_internal equivalent in Pexpect

I have recently started with pexpect and trying to learn it through the analogy with Tcl/Expect. Since I am come from the Tcl/Expect background, I believe there must be something like "exp_internal".
Can someone let me know what is equivalent of "exp_internal" of Tcl/Expect in pexpect terminology.
PS: exp_internal in Tcl/Expect prints all the log messages produced by the internal regex engine. It clearly shows what was the buffer received by the expect and what regular expression it matched or did't match.
EDIT
No answer seems to have existed back when the question was posted. I will just try to edit the question with hope that there now is an answer.
There is no such feature in pexpect

Erlang and current date time

I would like to get a current date time with erlang.
I have tried using the code below;
{{Year,Month,Day},{Hour,Min,Sec}} = erlang:localtime().
But sometimes it got an error like '** exception error: no match of right hand side value {{2012,5,6},{23,40,58}}'
Looks like there is a problem with 1 digit. I try searching couple of webs but still cannot find a way to cope this.
I believe this is quite an easy one but as a erlang newbie, I cannot resolve this. I try my best.
Env:
Erlang {"OTP APN 181 01","R15B01"} installed with windows binary version
Windows XP
Thanks in advance,
No, there is no problem with 1 digit. It should match perfectly well (check with {{Year,Month,Day},{Hour,Min,Sec}} = {{2012,5,6},{23,40,58}}). Most likely you have already assigned one of the variables to something earlier in the function.

Is it possible to add multiple commands to the readline .inputrc file?

I'm trying to configure my Terminal and I would like to insert #{} at one key-stroke. This works with the following code
# .inputrc
"\e\"": "#{}"
But I also want the cursor to end up inside the braces. How can I do this? The following doesn't work.
# .inputrc
"\e\"": "#{}": backward-char
Try:
"\e\"": "#{}\e[D"
My immediate way to fix your overall goal (not really answering your question, but hopefully helping you anyway): write a bash alias or function for it. grev() perhaps, or something similar - at least, this is what I would do were I in your situation.
I am interested to see if what you originally asked is possible, however, so voting up your question in hopes that you can get a 'real answer'!

Resources