Python Forum
I'm not sure what I'm doing wrong here...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I'm not sure what I'm doing wrong here...
#2
For starters:

Your number1 code
number1 = raw_input("Choose a number.")
def number1():
    if number1 <= 1:
        number1 = "a"
    elif number1 > 1:
        number1 = number1
Very confusing and potential for error exists (even though technically legal) when variables are named the same as functions
also you don't need the elif it does nothing.Why would you have to make a variable equal to itself?
You should also refrain from using globals, but that's something you will pick up with experience ... just keep it in the back of your mind.
In addition, if you're going to the trouble of naming something 'number'... don't store anything but numbers in that variable
finally, you never call this function, so why is it there? and even if you did, you never look for an 'a'

to execute a function, the syntax is functionname(arguments). I think you are confused about this.
defaults should only be used if they make sense, not as a standard way to call a function.
your final_product is a good example of BAD code.

Try fixing things up a bit, then come back with specific issues.
also, next time post the code here (unless it's mile long)
Reply


Messages In This Thread
I'm not sure what I'm doing wrong here... - by Fazz - Nov-01-2016, 01:44 AM
RE: I'm not sure what I'm doing wrong here... - by Larz60+ - Nov-01-2016, 04:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,977 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  python gives wrong string length and wrong character thienson30 2 3,152 Oct-15-2019, 08:54 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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