Python Return Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings python invalid syntax error and policies of this site About Us Learn more about Stack Overflow
Syntaxerror: Invalid Syntax
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation python syntax error Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it
Try Python
only takes a minute: Sign up Python Return Invalid Syntax Error up vote 1 down vote favorite 1 I am writing a simple python program on a raspberry pi and I am quite new to python programming. I have defined a function called GetMessage which has no parameters and returns a variable which I called data, but I am getting an python if error which states File "Raspberry_pi.py", line 39 return none ^ SyntaxError: invalid syntax import os import glob import time import RPi.GPIO as GPIO from math import * from bluetooth import * from RPIO import PWM os.system('sudo hciconfig hci0 pisca') os.system('sudo hciconfig hci0 name "De Quadcoptur"') servo = PWM.Servo() StartSpin() server_sock=BluetoothSocket( RFCOMM ) server_sock.bind(("",PORT_ANY)) server_sock.listen(1) port = server_sock.getsockname()[1] GetMessage() DecodeInput() uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee" def GetMessage(): advertise_service( server_sock, "XT1032", #phone bluetooth name service_id = uuid, service_classes = [ uuid, SERIAL_PORT_CLASS ], profiles = [ SERIAL_PORT_PROFILE ], #protocols = [ OBEX_UUID ] ) client_sock, client_info = server_sock.accept() try: data = client_sock.recv(1024) if len(data) == 0: break print "received [%s]" % data client_sock.close() server_sock.close() except IOError: pass break return data def StartSpin(): # Set servo on GPIO17 to 1200µs (1.2ms) servo.set_servo(17, 1000) servo.set_servo(18, 1000) servo.set_servo(19, 1000) servo.set_servo(20, 1000) time.sleep(1) servo.stop_servo(17) servo.stop_servo(18) servo.stop_servo(19) servo.stop_servo(20) #Check if more pulses is faster time.sleep(2000) PWM.add_channel_pulse(0, 17, start = 1000, width = 100) PWM.add_channel_pulse(0, 17, start = 1000, width = 100) PWM.add_channel_pulse(0, 17, start = 1000, width = 100) PWM.add_channel_pulse(0, 17, start = 1000, width = 100) PWM.add_channel_
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Python Open
of this site About Us Learn more about Stack Overflow the company
Python For Loop
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a http://stackoverflow.com/questions/29185596/python-return-invalid-syntax-error minute: Sign up Python return statement wont work? up vote 1 down vote favorite def savings (pocket_money, paper_route, spending): --- return pocket_money + paper_route - spending print (savings (10, 10, 5)) This code says that there is a syntax error where print is. Idk whats wrong, i got that code from a beginner to python book. I tried several more examples from http://stackoverflow.com/questions/25173593/python-return-statement-wont-work the book that involve the return statement, and all gave me a syntax error where print is. One thing I noticed was that when I press ENTER on the return statement the cursor appears with no spaces, as in ending the block. Idk if this is normal; I just started learning python a few days ago. I am using Python 3.4.1 function python-3.x syntax-error return share|improve this question asked Aug 7 '14 at 3:22 Elvis 82 can you paste the error trace? –levi Aug 7 '14 at 3:24 To use a code block on stack overflow, add 4 spaces in front of each line of code. To put some words into a code block, surround with backticks: ` –NuclearPeon Aug 7 '14 at 3:32 def savings(pocket_money, paper_route, spending): return pocket_money + paper_route - spending print(savings(10, 10, 5)) SyntaxError: invalid syntax –Elvis Aug 7 '14 at 3:39 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted Here's what I get $ python -V Python 2.7.3 $ python >>> def s(pm,pr,s): ... retu
you have probably seen some. There are (at least) two distinguishable kinds of errors: syntax errors and exceptions. 8.1. Syntax Errors¶ Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while https://docs.python.org/2.7/tutorial/errors.html you are still learning Python: >>> while True print 'Hello world' File "
runtime system and by human readers). Contents 1 Design philosophy 2 Keywords 3 Indentation 4 Data structures 4.1 Base types 4.2 Collection types 4.3 Object system 5 Literals 5.1 Strings 5.1.1 Normal string literals 5.1.2 Multi-line string literals 5.1.3 Raw strings 5.1.4 Concatenation of adjacent string literals 5.2 Numbers 5.3 Lists, tuples, sets, dictionaries 6 Operators 6.1 Arithmetic 6.2 Comparison operators 6.3 Logical operators 7 Functional programming 7.1 Comprehensions 7.2 First-class functions 7.3 Closures 7.4 Generators 7.5 Generator expressions 7.6 Dictionary and set comprehensions 8 Objects 8.1 With statements 8.2 Properties 8.3 Descriptors 8.4 Class and static methods 9 Exceptions 10 Comments and docstrings 11 Function annotations 12 Decorators 13 Easter eggs 14 References 15 External links Design philosophy[edit] Python was designed to be a highly readable language.[1] It has a relatively uncluttered visual layout and uses English keywords frequently where other languages use punctuation. Python aims towards simplicity and generality in the design of its syntax, encapsulated in the mantra "There should be one—and preferably only one—obvious way to do it", from "The Zen of Python".[2] This mantra is deliberately opposed to the Perl and Ruby mantra, "there's more than one way to do it". Keywords[edit] Python has the following keywords or reserved words; they cannot be used as identifiers.[3][4] and as assert async[note 1] await[note 1] break class continue def del elif else except exec[note 2] False[note 3] finally for from global if import in is lambda None nonlocal[note 3] not or pass print[note 2] raise return True[note 3] try while with yield Notes ^ a b Starting from Python 3.5, async and await were introduced.[5] ^ a b Starting from Python 3, exec and print are functions, so they are not keywords anymore. ^ a b c Starting from Python 3, keywords True, False and nonlocal were introduced. Indentation[edit] Python uses whitespace to delimit control flow blocks (following the off-side rule). Python borrows this feat