Help with a small python line

This is the place for queries that don't fit in any of the other categories.

Help with a small python line

Postby Bjoern89 » Tue Sep 17, 2013 9:10 am

I just started with python yesterday at work, and I'm slowly working myself up the learning curve.

Firstly I can't seem to get the following to run in python, it simply opens and shuts down again:

Code: Select all
def clinic():
    print "Du har akkurat kommet inn på IKT-avdelingen!"
    print "Onsker du å snakke med Bjorn-Tore eller Morten??"
    answer = raw_input("Skriv Bjorn eller Morten og trykk deretter 'Enter'.").lower()
    if answer == "bjorn" or answer == "b":
        print "Her er det ikke hjelp å faa, snakk heller med morten!"
    elif answer == "morten" or answer == "m":
        print "Dette skal vi faa til!"
    else:
        print "Du onsket altså ikke å snakke med noen av dem?"
        clinic()

clinic()


Secondly, I was wondering if there's any suggestions on other sites that would be helpful to people who are new to python outside of http://www.codecademy.com/ which i'm currently using?

Thank you in advance,
Bjoern
Last edited by stranac on Tue Sep 17, 2013 9:21 am, edited 1 time in total.
Reason: Added code tags, locked post
Bjoern89
 
Posts: 3
Joined: Tue Sep 17, 2013 9:06 am

Re: Help with a small python line

Postby stranac » Tue Sep 17, 2013 9:26 am

How are you running this?
If you run it from a terminal, you will be able to see exactly what the error is.
Then, if you still need help fixing it, post the entire error traceback here, in code tags.

Also, read the new users sticky thread.
If it looks to me like you haven't read it, I will delete your future posts without warning.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: Help with a small python line

Postby Bjoern89 » Tue Sep 17, 2013 9:30 am

Hi Stranac. I didn't read the guideline before I put out my post I'm afraid as I was sort of rushing to figure this out, however I went on reading it after I posted, but my thread wasn't visible again until a moderator read it.

I have python 2.75 installed on my computer and when I click the file on my desktop to open in python, the window simply appears and then vanishes half a second later.
Bjoern89
 
Posts: 3
Joined: Tue Sep 17, 2013 9:06 am

Re: Help with a small python line

Postby stranac » Tue Sep 17, 2013 9:38 am

I understand.
That could mean two things:
  1. Your program finished running and closed normally
  2. There was an error that caused your program to end
That's why you should always run python programs from a terminal(cmd.exe on windows).
That will let you see exactly what is going on.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: Help with a small python line

Postby Bjoern89 » Tue Sep 17, 2013 9:51 am

The code actually worked by running it with idle from Python. Thanks for your help, and sorry for the previous forum violation :)
Bjoern89
 
Posts: 3
Joined: Tue Sep 17, 2013 9:06 am

Re: Help with a small python line

Postby Kebap » Tue Sep 17, 2013 10:12 am

Problem with Windows here: It will close the python program quickly, so you can't read any of the (wanted or errorneus) output before. In the beginning, I just added an input() to the end of my program, so I had to press Enter before the program would be closed giving me time to analyse the outputs. However, going through the command line or a GUI is recommended.
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 396
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: Help with a small python line

Postby Hissing Cockroach » Thu Sep 19, 2013 1:47 am

all you have to do is remove the little bubbles above the a.
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm
Location: Earth


Return to General Coding Help

Who is online

Users browsing this forum: metulburr, snippsat and 5 guests