Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22nd March 2012, 06:22 PM
BrandonAdam Offline
Registered User
 
Join Date: Feb 2012
Location: canada
Posts: 11
windows_7firefox
Fedora 16 'python' syntax error

hello,

I'm trying to get to know python and it seems to be very similar to bash with some subtle differences here and there. I've been working a few examples in a book that I have and after I've input the code listed below I keep getting a syntax error and I cannot figure out where the problem lies, any ideas?


#!/usr/bin/python3


Function myTeams( teamname )
print('My favorite team is','!')

myFunction('Gators')
myFunction('Cowboys')
myFunction('Patriots')
myFunction('Redsox')
myFunction('Yankees')
Reply With Quote
  #2  
Old 22nd March 2012, 08:41 PM
RupertPupkin's Avatar
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 4,616
linuxfedorafirefox
Re: Fedora 16 'python' syntax error

Quote:
Originally Posted by BrandonAdam View Post
I've been working a few examples in a book that I have
Is that book titled "How Not to Write Functions in Python"?
Because the syntax you're using has nothing in common with Python.
Try this:
Code:
def myTeams(teamname):
    print "My favorite team is",teamname
myTeams("Gators")
That second line (the one with the print statement) is indented with a tab. You have to indent with tabs in Python, which is one reason why many programmers detest the language. Any way, good luck.
__________________
OS: Fedora 18 x86_64 | CPU: AMD64 3700+ 2.2GHz | RAM: 2GB PC3200 DDR | Disk: 160GB PATA | Video: ATI Radeon 7500 AGP 64MB | Sound: Turtle Beach Santa Cruz CS4630 | Ethernet: Realtek 8110SC
Reply With Quote
  #3  
Old 22nd March 2012, 09:26 PM
woelfman10 Offline
Registered User
 
Join Date: Aug 2008
Location: Minnesota
Posts: 68
linuxfirefox
Re: Fedora 16 'python' syntax error

Quote:
Originally Posted by RupertPupkin View Post
You have to indent with tabs in Python, ...
You don't have to indent with tabs, but you do need a consistent column width. Just don't mix tab and space indenting in the same file.
Reply With Quote
  #4  
Old 22nd March 2012, 10:49 PM
BrandonAdam Offline
Registered User
 
Join Date: Feb 2012
Location: canada
Posts: 11
windows_7firefox
Re: Fedora 16 'python' syntax error

wow, ok great! thank you for the information =D

---------- Post added at 03:49 PM ---------- Previous post was at 03:38 PM ----------

got it to work with slight changes;

print("My favorite team is", teamname)

that's it

~thanks for your help!
Reply With Quote
Reply

Tags
error, fedora, python, syntax

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB 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
Yum + Python syntax error DarkMasterHalo Using Fedora 10 12th September 2008 02:46 PM
Parse error: syntax error, unexpected T_STRING in /home/wwwroot/phpMyAdmin-2.6.2/libr marco75 Servers & Networking 0 18th December 2006 02:35 AM


Current GMT-time: 01:42 (Monday, 20-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat