Hack Forums
[Python] Code won't run | No terminal error | Help if possible? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Code won't run | No terminal error | Help if possible? (/showthread.php?tid=5524533)



Code won't run | No terminal error | Help if possible? - averagejoee - Jan 15, 2017

Hello, bit of a weird issue. I have written some code in Sublime text 3 and when trying to run in terminal it displays something for literally a micro second and stops running.

Here is a preview of the code:

htt ps://gyazo.com/97d4d389c53085163b4ba1acb612a42e

Edit: I would really appreciate some help - I have a deadline :(


* - Stoels - Jan 15, 2017

Could you show me a screenshot of the error you are getting?


* - averagejoee - Jan 15, 2017

No error. The code seems to run, do nothing then stop


* - Stoels - Jan 15, 2017

So your terminal looks like the example below after running?

user@host~$ python test.py
user@host~$


* - averagejoee - Jan 15, 2017

Yes. Looks exactly like that.

Exactly: python test.py testerrors.xls output.txt 1.6


* - Stoels - Jan 15, 2017

Could you try to put a print command before checkData() and in both for loops?


* - averagejoee - Jan 15, 2017

Scrap that issue seemed to resolve it. New one now!

Terminal output:

Traceback (most recent call last):
File "test.py", line 43, in <module>
handleCommandlineArgs()
File "test.py", line 23, in handleCommandlineArgs
checkData()
File "test.py", line 32, in checkData
numtoalpha = dict(zip(range(0, 26), string.ascii_lowecase))
AttributeError: 'module' object has no attribute 'ascii_lowecase'


* - Hello Buddy - Jan 15, 2017

You spelt lower_case wrong. Replace it with string.ascii_lowercase


* - Stoels - Jan 15, 2017

I has a typo. It should say string.asci_lowercase 🙂


* - averagejoee - Jan 15, 2017

Thank you very much guys I do appriceate it


Last quick question. Do you have any idea why my prints are not printing out in the statement. You can see it is saying '2.0, 2.0, 2.0' etc. However it should be saying 'hello 2.0, hello 2.0'

ht tps://gyazo.com/addd53a39a3b13cf1982ad51d38690b3
ht tps://gyazo.com/4cf0cf0e9189df191fc486bed3f19201


* - Hello Buddy - Jan 15, 2017

From what I can see is that if the column is 1 then it will print out something like:
hello
Found: 2.0
Since they're in different print statements. Otherwise, it will just print:
Found: 2.0


* - Goodies - Jan 16, 2017

You really, really should not be using globals like that. Global variables should not be initialized in functions.