hi,
I'm learning Python and when I compile one of the exercises from the course, the results come strikingly different than the original version. This is not me solving an exercise! It is an example that I ran from file & interpreter, and the results I receive are different (similar on my machine, but different than other machines).
I posted on the Python forum, but there's no solution yet https://python-forum.io/Thread-py4e-boo ... n-compiled
I was thinking maybe there is a package issue...
Any ideas?
Thanks!
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[Solved] python code gives different results on my machine
[Solved] python code gives different results on my machine
Last edited by adido on 2018-06-13 11:46, edited 1 time in total.
-
- Posts: 1101
- Joined: 2016-01-07 12:25
- Has thanked: 5 times
- Been thanked: 16 times
Re: python code gives different results on my machine
I just tested in my Jessie machine and got this output
I also tested in my Buster installation and get the same (correct) results just with newer Python and GCC versions, which leads me to think there could be a problem with your python installation (just a guess really).
Code: Select all
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
>>> atpos = data.find('@')
>>> print (atpos)
21
>>> spos = data.find(' ',atpos)
>>> print (spos)
31
>>> host = data[atpos+1 : spos]
>>> print (host)
uct.ac.za
Re: python code gives different results on my machine
My bet is that the space (' ') is not a real space but something you've copied over from HTML (  or who knows what).
Type the program yourself, with a normal (ASCII) editor.
Type the program yourself, with a normal (ASCII) editor.
- sunrat
- Administrator
- Posts: 6476
- Joined: 2006-08-29 09:12
- Location: Melbourne, Australia
- Has thanked: 118 times
- Been thanked: 474 times
Re: python code gives different results on my machine
+1 for what reinob said. I had the same problem recently.
See http://forums.debian.net/viewtopic.php? ... 02#p675102
See http://forums.debian.net/viewtopic.php? ... 02#p675102
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
[Solved] python code gives different results on my machine
son of a...reinob wrote:My bet is that the space (' ') is not a real space but something you've copied over from HTML (  or who knows what).
Type the program yourself, with a normal (ASCII) editor.
Thank you, there was a problem with space in the string I believe... I first edited the (' ') and had the same results. Then I re-did all the spaces in the string and it all worked!
Many thanks!
Re: [Solved] python code gives different results on my machi
Good you got this solved. One thing that could be used, is to paste to some word processing program (tested with Abiword), which can show nonprintable characters.adido wrote:son of a...reinob wrote:My bet is that the space (' ') is not a real space but something you've copied over from HTML (  or who knows what).
Type the program yourself, with a normal (ASCII) editor.
Thank you, there was a problem with space in the string I believe... I first edited the (' ') and had the same results. Then I re-did all the spaces in the string and it all worked!
Many thanks!