Python Forum
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Def Command
#1
I have a couple questions about the command "def". Once you define something, say "greeting", and you write your script in it:

def greeting():
name = input('What's your name?')
print('Hi,', name.title())
age = input('How old are you?')
if age > 18:
print('Nice.')
So you define greeting, but you want to continue that outside of the "def" command, like:

greeting()
else:
print('Oh')
Can I continue a "if then" statement outside of defining a variable? Also, I use "greeting somewhere, after python has run the script, will it continue down the script? Say I want to go to a specific spot of code depending on how the user input is answered, how would I do that? Thanks
Reply


Messages In This Thread
Def Command - by Trinx - Jan-15-2019, 02:41 AM
RE: Def Command - by ichabod801 - Jan-15-2019, 02:56 AM
RE: Def Command - by Trinx - Jan-15-2019, 03:33 AM
RE: Def Command - by ichabod801 - Jan-15-2019, 03:55 AM

Forum Jump:

User Panel Messages

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