Suddenly Pythias 3 seems to want me to use raw_input not input()?
I don't see why?
thx
Re: input()
Thanks but it will only work if I use raw_input() and yes it is Python 3. This is the mystery
Re: input()
Code: Select all
from time import sleep, time
from random import randint
while True:
sleep(randint(1,5))
start = time()
print('Quick, hit the Enter key')
raw_input() #had to change input() to raw_input() for it to work
reaction_time = time() - start
print('You took', reaction_time, 'seconds')
Re: input()
You missed the CODE tags, which I have now added, but the formatting (indentation) is still missing.katyp wrote:Code: Select all
from time import sleep, time from random import randint while True: sleep(randint(1,5)) start = time() print('Quick, hit the Enter key') raw_input() #had to change input() to raw_input() for it to work reaction_time = time() - start print('You took', reaction_time, 'seconds')
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
Re: input()
Are you absolutely sure you are running it with Python3? Python3 doesn't have raw_input() unless something else implements it. How are you running your program? You can add the following to the start of the program to print out which version of Python is running the program just to be sure.katyp wrote:Thanks but it will only work if I use raw_input() and yes it is Python 3. This is the mystery
Code: Select all
import sys
print(sys.version)
Code: Select all
pi@rpi3:~ $ python3 ver.py
3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1]
pi@rpi3:~ $ python ver.py
2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2]
Code: Select all
('You took', 0.6783080101013184, 'seconds')
Kira the Koding Kitty, R.I.P. 8/3/24
Re: input()
Texy
No sure what you mean by code tags? The programme has the indents and runs OK as is - just lost indent in copying and pasting Yes it is Python 3
No sure what you mean by code tags? The programme has the indents and runs OK as is - just lost indent in copying and pasting Yes it is Python 3
Re: input()
texy wrote:You missed the CODE tags, which I have now added, but the formatting (indentation) is still missing.katyp wrote:Code: Select all
from time import sleep, time from random import randint while True: sleep(randint(1,5)) start = time() print('Quick, hit the Enter key') raw_input() #had to change input() to raw_input() for it to work reaction_time = time() - start print('You took', reaction_time, 'seconds')
Texy
Texy
No sure what you mean by code tags? The programme has the indents and runs OK as is - just lost indent in copying and pasting Yes it is Python 3
Re: input()
Code tags are what you need to use to mark sections of your post as code so that it gets displayed exactly as given including all white space (multiple spaces, tabs). You can either insert the tags using the Code button which is the 5th button just above the text entry box, or you can type them in yourself. By pressing the button the start and end tags [code] & [/code] will be inserted for you with the cursor inbetween ready for you to put your code (or you can highlight a section of your post and press the button, the tags will then be placed either side of the highlighted section).katyp wrote:Texy
No sure what you mean by code tags? The programme has the indents and runs OK as is - just lost indent in copying and pasting Yes it is Python 3
As to your program, as has been said, if your code uses raw_input() and runs then you are not using Python3 to run it, you are using Python2. Python3 does not have a function called raw_input unless you define it yourself (and your program doesn't do that). What makes you think that you are running it with Python3?
Kira the Koding Kitty, R.I.P. 8/3/24