Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to python. Please help
#1
Can someone please explain what is wrong with the function. I am reading an old version of Python Programming by John Zelle

def main():
     x = input("Enter a number between 0 and 1: ")
Reply
#2
The problem is that you define the function without calling it. Add main() after to call / invoke the function.

By the way, there's probably not much reason to use an old book. I'd recommend Think CS as a great tutorial, but if it doesn't suit your taste then I recommend our tutorials section.

The only thing I recommend you avoid is "Learn Python the Hard Way." I like the title in theory but the author, to put it as nicely as possible, is known to put his foot in his mouth and it can be extremely confusing / misleading for new programmers.
Reply


Forum Jump:

User Panel Messages

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