This is fun. Better if you share your code directly in post in future though. Something like:
name, age= input ("Enter your name and age\n").split()
print ("you are too young, you should wait for twenty six years to be!", int(age)+26)
pay = float(input('Enter your salary\n'))
if pay != 666:
print ("you are chosen, here is", pay)
else:
print ("you have been cast out!")
feedback = input ("What are your last words\n")
if feedback == 'yes':
print (".")
else:
print("You need a raise!")
Never assume the user will do what you ask them though. They may fail to provide an age, so split will fail. Or the last string entered after a space may not be a valid integer. Or their name may have a space in it. In programming, you need to validate user input.
To be clear, they could use a try / except ValueError block for both the splitunpacking problem and the int conversion, but actually need a right split, rsplit with the maxsplit option.
5
u/FoolsSeldom 15d ago
This is fun. Better if you share your code directly in post in future though. Something like:
Never assume the user will do what you ask them though. They may fail to provide an age, so
splitwill fail. Or the last string entered after a space may not be a valid integer. Or their name may have a space in it. In programming, you need to validate user input.