Keep on sailing

Report a typo

Redefine the method sail of our class Ship so that it would take the destination and then tell where the ship is going. Call this method on the black_pearl object that's defined in the code below and print the returned message.

Note: you should read the destination from input!

The input format:

The name of the country or the city where the ship is going.

The output format:

The result of the updated sail method: a message structured like "The {name of the ship} has sailed for {country/city}!"

Sample Input 1:

Argentina

Sample Output 1:

The Black Pearl has sailed for Argentina!
Write a program in Python 3
# our class Ship
class Ship:
def __init__(self, name, capacity):
self.name = name
self.capacity = capacity
self.cargo = 0

# the old sail method that you need to rewrite
def sail(self):
return "{} has sailed!".format(self.name)


black_pearl = Ship("Black Pearl", 800)
___

Create a free account to access the full topic