Hello and welcome to CertForums.co.uk, here we host free active certification forums with links to the best free resources for Microsoft's MCSA MCSE MCDBA Cisco's CCNA CCDA and CCNP, and CompTIA's A+ Network+ i-NET+ and Security+ certifications in the UK. If you wish to post or use other advanced features you will need to register first. Registration is absolutely free and takes only a few minutes to complete so sign up today!

If you have any problems with the registration process or your account login, please contact support

Go Back   CertForums > Computing Support Forums > Programming & Scripting
Home Forums Register Search Today's Posts Mark Forums Read

What am I doing wrong?

Post New ThreadReply
 
Thread Tools Display Modes
  #1  
Old 11-Mar-2008, 05:44 PM
OceanPacific's Avatar
OceanPacific OceanPacific is offline
Valued Member
Posts: 140
Points: 1 OceanPacific has between 1 & 100 points
Power: 3
None
Join Date: 04 Feb 2008
Location: In my mind im in California
Age: 21
WIP: N+, A+
What am I doing wrong?

Im typing this into python:

n = input("Number? ")
if n < 0:
print "The absolute value of" ,n,"is",-n
else:
print "The absolulte value of",n,"is",n


And its giving me a syntax error on "Else"??? Im doing exactly like the guidebook says. Any thoughts?

 
Reply With Quote
  #2  
Old 11-Mar-2008, 06:28 PM
tripwire45's Avatar
tripwire45 tripwire45 is offline
Administrator
Posts: 13,477
Points: 4044 tripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 pointstripwire45 has over 4000 points
Power: 184
None
Join Date: 29 Jun 2003
Location: Boise, ID, USA
Certifications: A+ and Network+
Indentation error. "else" can't be indented. Here's what I did to make it work for me:
Code:
n = input("Number? ")
if n < 0:
     print "The absolute value of" ,n,"is",-n
else:
     print "The absolute value of",n,"is",n
Python is sensitive to indentation. Tell me, are you learning from "Non-Programmers Tutorial For Python"? I had the identical exercise when studying from this source. Hope this helps.


You know, I wish my parents played Mozart when I slept because half the time I don't even know what the heck anyone's talking about!
 
Reply With Quote
  #3  
Old 11-Mar-2008, 06:37 PM
OceanPacific's Avatar
OceanPacific OceanPacific is offline
Valued Member
Posts: 140
Points: 1 OceanPacific has between 1 & 100 points
Power: 3
None
Join Date: 04 Feb 2008
Location: In my mind im in California
Age: 21
WIP: N+, A+
Quote:
Originally Posted by tripwire45 View Post
Indentation error. "else" can't be indented. Here's what I did to make it work for me:
Code:
n = input("Number? ")
if n < 0:
     print "The absolute value of" ,n,"is",-n
else:
     print "The absolute value of",n,"is",n
Python is sensitive to indentation. Tell me, are you learning from "Non-Programmers Tutorial For Python"? I had the identical exercise when studying from this source. Hope this helps.

Awesome, thanks Tripwire!

Yes, I am learning from that guide. So far so good, though I have caught a few small mistakes, but its a free publication so you cant complain too much.

I printed the PDF out at work and bound it so its like a real book!

 
Reply With Quote
Post New ThreadReply Spread this thread: Submit this thread to digg Submit this thread to del.icio.us


Go Back   CertForums > Computing Support Forums > Programming & Scripting


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
It's so so wrong Arroryn Just for Laughs 13 24-Feb-2008 09:20 PM
I am in the wrong job... GiddyG The Lounge - Off Topic 12 04-Feb-2008 05:09 PM
What's wrong with my CV? Grahamuk2008 Employment & Jobs 12 03-Feb-2008 05:55 AM
Whats wrong? Mr.Cheeks The Lounge - Off Topic 6 26-Jul-2006 05:21 PM
A Trend in the Wrong direction Phoenix Security & Viruses 3 03-May-2005 02:33 PM


All times are GMT. The time now is 10:00 PM.

Powered by vBulletin® Version 3.6.11
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
CertForums.co.uk (C) copyright 2003-2007 All Rights Reserved. Content published on CertForums.co.uk requires permission for reprint.
Hosted by Lunarpages