Search code examples
pythonpython-3.xpython-2.7symbols

Cant print inch and feet symbols in function


Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints using ' and " shorthand. End with a newline. Remember that print() outputs a newline by default. Ex: print_feet_inch_short(5, 8) prints: 5' 8"

My code:

def print_feet_inch_short(num_feet, num_inches):
    return print(num_feet , num_inches )
''' Your solution goes here '''

user_feet = int(input())
user_inches = int(input())

print_feet_inch_short(user_feet, user_inches) # Will be run with (5, 8), then (4, 11)

When i compile my code i get 5 8 instead of 5' 8" Please help me to get the inch and feet symbols in the function

Thanks in advance


Solution

  • Try:

    def print_feet_inch_short(num_feet, num_inches):
        print(f"{num_feet}' {num_inches}\"")
    

    Usage:

    >>> print_feet_inch_short(5, 8)
    5' 8"