Question: Write a function named right_justify that takes a string named input_string as a parameter. If the input string is longer than 79 characters, the string
Write a function named right_justify that takes a string named input_string as a parameter. If the input string is longer than 79 characters, the string should be printed as is, Otherwise, the function should print the string with enough leading spaces that the last letter of the string is in column 80 of the display. (Note: Python has an inbuilt function called len that returns the length of a string. You can use this function to help perform the task).
def right_justify(input_string):
pass # TODO: Complete a function
value = input("Enter string to justify: ")
right_justify(value)
TESTS :
Short string
Expected Output
Enter string to justify: hello
Long string
Expected Output
Enter string to justify: This is a longer string that does not actually need to be justified. It is already long enough.
This is a longer string that does not actually need to be justified. It is already long enough.
Under limit string
Expected Output
Enter string to justify: This string is exactly 79 characters long & so does require some justification.
This string is exactly 79 characters long & so does require some justification.
Over limit string
Expected Output
Enter string to justify: This string is exactly 80 characters long and so does not require justification.
This string is exactly 80 characters long and so does not require justification.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
