class Begin:
def __init__(self, firstname, lastname, year):
self.firstname = firstname
self.lastname = lastname
self.year = year
print('Welcome to the interactive decision matrix! ')
firstname = input(f'Please begin with entering your first name: ')
lastname = input('Last name ?')
year = input('Year? ')
make_sure = input(f'Just to make sure, your name is {firstname} {lastname}, and the year is {year} ? (Y/N)')
if make_sure.lower() == 'y':
pass
else:
**Begin(__init__()) #Doesn't recognises the class? How do I go back?**
print('Hello')
Asked
Active
Viewed 37 times
-2

fuglede
- 17,388
- 2
- 54
- 99

ThomasReiner
- 43
- 8
-
1You're code is bad indentd please correct it – azro Apr 07 '20 at 10:34
-
1Why doing those things in `__init__()` or in the class? I would do them outside the class. – muyustan Apr 07 '20 at 10:34
-
2It's unclear whether the indentation of your code in the question is correct, it's unclear what you want to do and it's unclear what you want to know. There's only one thing that is clear: you need to learn more about OOP. – Matthias Apr 07 '20 at 10:41
-
@Matthias Will do. Sorry for the noob question. I just want to restart the code if the answer is 'n' or ''N'' – ThomasReiner Apr 07 '20 at 10:44
-
@Bishop1701 This might be something you want to read [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – Matthias Apr 07 '20 at 11:02
1 Answers
0
class Begin:
def __init__(self, firstname, lastname, year):
self.firstname = firstname
self.lastname = lastname
self.year = year
def main():
print('Welcome to the interactive decision matrix! ')
while True:
firstname = input(f'Please begin with entering your first name: ')
lastname = input('Last name ?')
year = input('Year? ')
make_sure = input(f'Just to make sure, your name is {firstname} {lastname}, and the year is {year} ? (Y/N)')
if make_sure.lower() == 'y':
begin = Begin(firstname, lastname, year)
break
print(f'Hello, your name is {begin.firstname} {begin.lastname}, and the year is {begin.year}.')
if __name__ == '__main__':
main()

Alex Hall
- 34,833
- 5
- 57
- 89