Posts: 6
Threads: 1
Joined: May 2018
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.')
Posts: 8,167
Threads: 160
Joined: Sep 2016
(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?
Posts: 6
Threads: 1
Joined: May 2018
(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.
Posts: 8,167
Threads: 160
Joined: Sep 2016
did you read my last question? doesn't it ring a bell?
Posts: 6
Threads: 1
Joined: May 2018
(May-05-2018, 05:59 PM)buran Wrote: did you read my last question? doesn't it ring a bell? Well, no not really.
Posts: 8,167
Threads: 160
Joined: Sep 2016
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.
Posts: 6
Threads: 1
Joined: May 2018
(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
Posts: 8,167
Threads: 160
Joined: Sep 2016
May-05-2018, 06:55 PM
(This post was last modified: May-05-2018, 08:13 PM by buran.)
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
Posts: 6
Threads: 1
Joined: May 2018
(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()
Posts: 8,167
Threads: 160
Joined: Sep 2016
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.
|