Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help
#1
Hey guys, I am very new to Python and messing around with some coding. I am trying to create an Information Program which prints out the information provided in a sentence if you want. I have an issue though, the part in which the user decides if they want the information in a sentence doesn't seem to work. Any help will be appreciated.
#Information about you
print('''
Welcome to the Information Program!
''')
first_name = input('What is your First Name?')
print('Your first name is %s. ' % first_name)
surname = input('What is your Surname?')
print('Your Surname is %s. ' % surname)
print('So, your full name is %s %s ' % (first_name,surname))

dob = input('What is your Date of Birth?')
print('Your date of birth is %s. ' % dob)

birth_place = input('Where were you born?')
print('You were born in %s. ' % birth_place)

def decision():
    decision1 = input('''
Do you want your Full Information?
Type Y for YES or N for NO.
''')
    if decision1.upper() == 'Y':
      print('''
      Your Full name is %s %s, you were born on the %s, and born in %s. ''' % (first_name, surname, dob, birth_place))
    elif decision1.upper() == 'N':
      print('Okay, thank you for using the Information Program!')
    else: 
      print('You have typed in an invalid answer, please run the program again.')
Reply
#2
(May-05-2018, 05:06 PM)Volby Wrote: doesn't seem to work
does not tell us much...
do you get an error? it doesn't do what is expected?
or maybe you don't call function decision at all?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(May-05-2018, 05:44 PM)buran Wrote:
(May-05-2018, 05:06 PM)Volby Wrote: doesn't seem to work
does not tell us much...
do you get an error? it doesn't do what is expected?
or maybe you don't call function decision at all?

Yeah sorry, might have not been entirely descriptive. Basically after the code:
birth_place = input('Where were you born?')
print('You were born in %s. ' % birth_place)
Nothing shows up, I don't get an error or anything. This is what the output of the code looks like https://gyazo.com/7b66d3ab85334387fe67d05538c5cf1f.
It just sort of ignores? the decision code.
Reply
#4
did you read my last question? doesn't it ring a bell?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(May-05-2018, 05:59 PM)buran Wrote: did you read my last question? doesn't it ring a bell?
Well, no not really.
Reply
#6
on line 17-28 you define a function - decision. So well, this is exactly that - definition. in order to execute the function you need to call it. add
decision()
at the end of your code.
Note that this is not best way to structure your code, but at least it will work.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
(May-05-2018, 06:05 PM)buran Wrote: on line 17-28 you define a function - decision. So well, this is exactly that - definition. in order to execute the function you need to call it. add
decision()
at the end of your code.
Note that this is not best way to structure your code, but at least it will work.

Just tried that, still nothing happens
Reply
#8
Post the code you have tried...
We don't have crystal ball to see what you try...
Note that the line I suggest must not be part of the function. I.e. it must not be indented
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
(May-05-2018, 06:55 PM)buran Wrote: Post the code you have tried...
We don't have crystal ball to see what you try...
Note that the line I suggest must not be part of the function. I.e. it must not be indented

#Information about you
print('''
Welcome to the Information Program!
''')
first_name = input('What is your First Name?')
print('Your first name is %s. ' % first_name)
surname = input('What is your Surname?')
print('Your Surname is %s. ' % surname)
print('So, your full name is %s %s ' % (first_name,surname))

dob = input('What is your Date of Birth?')
print('Your date of birth is %s. ' % dob)

birth_place = input('Where were you born?')
print('You were born in %s. ' % birth_place)

def decision():
    decision1 = input('''
Do you want your Full Information?
Type Y for YES or N for NO.
''')
    if decision1.upper() == 'Y':
      print('''
      Your Full name is %s %s, you were born on the %s, and born in %s. ''' % (first_name, surname, dob, birth_place))
    elif decision1.upper() == 'N':
      print('Okay, thank you for using the Information Program!')
    else: 
      print('You have typed in an invalid answer, please run the program again.')
decision()
Reply
#10
So, what is the problem? Do you really want help? Help us to help you...

when I run this last code I get:

Output:
Welcome to the Information Program! What is your First Name?Buran Your first name is Buran. What is your Surname?Surname Your Surname is Surname. So, your full name is Buran Surname What is your Date of Birth?01.01.2000 Your date of birth is 01.01.2000. Where were you born?Earth You were born in Earth. Do you want your Full Information? Type Y for YES or N for NO. y Your Full name is Buran Surname, you were born on the 01.01.2000, and born in Earth.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

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