Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Post in Kali
#1
I tried my first coding in kali on python 3:

>>> !#/usr/bin/python3
... def main():
... print ("Hello Python!")
... if _name_ == "_main_" :

At this point I get File :<stdin>",line 1
if_name_=="_main_"
^
What am I doing wrong? I can't get past this.
Reply
#2
Please, use the Python code tags for future threads!

It's double underscore and you miss the ':' at the end of the line:

def main():
    print('Hello, Python!')

if __name__ == '__main__':
    main()
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Thank you I see now. I noticed that my font colors don't change when I try to input commands. I did the double underline bit I also hat to hit the enter key twice to change the Kali "..."s to >>>>. I have to figure out why my terminal text is not changing colors.
Reply
#4
When you run python interpreter from the terminal it has its own prompt which is >>>. The colour doesn't change. There is no syntax highlighting.
If you want that you have to install ptpython or ipython. You have to hit Enter twice because you can put multiple lines. An empty line tells to the interpreter that next Enter means executing the code.

You can install qtconsole for example.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python in Kali Linux coolcassie 2 7,137 Dec-02-2019, 12:48 PM
Last Post: coolcassie
  Run .py file in Kali Linux Terminal grayarea3 4 28,315 Feb-27-2019, 06:51 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020