Remember th
Instructions
- Write a function create_password() expects two parameters: pet_name (a string) and fav_number (an integer).
The function returns a new password generated using the following pattern:
fav_number followed by the pet_name followed by the star * and fav_number again (see the example below).
- Create a program that gets a pet name and a favorite number as input from the user, calls the above function, and then prints the output as shown below.
Example
Input:
Angel 3
Output:
Your new password is "3Angel*3".
Note that the double quotes are part of the output.
The assert in the provided template is checking that this function call is returning the correct value (i.e., a correctly-formed string).
assert create_password("Angel", 3) == "3Angel*3"
Hints
- Remember that you cannot directly concatenate an integer and a string - you need to convert an integer into a string using either str() or by using f-strings.
Troubleshooting
- If you are getting AssertionError make sure that your create_password() function is returning the correct value.
- If you are failing the Unit Tests but passing all of the "Compare Output" tests: make sure that your create_password() function is returning the correct value. This error is likely due to the if __name__ == '__main__': block printing the right value, but the function create_password() is not creating/returning the correct value.
provided code:
def _(_):
"""
The function expects
param: var_name (var_type)
The result is ...
"""
if __name__ == '__main__':
# TODO: Type your code here. Your code must call the function.
assert create_password("Angel", 3) == "3Angel*3"
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images