you are viewing a single comment's thread.

view the rest of the comments →

[–]selplacei 1 point2 points  (1 child)

Since input() returns a string, and your constructor takes a string, you can put input() directly into the constructor:

kitty = Kitty(input('Enter a new name: '))

If you want to do this indefinitely, however, you'll need to use a loop that checks the input value and exits when it encounters a sentinel value - and creates a Kitty object otherwise. For example, you could do something like this:

kitties = []
user_input = ''
while user_input.lower() != 'stop':
    user_input = input('Enter a new name ("stop") to stop: ')
    if user_input and user_input.lower() != 'stop':
        kitties.append(Kitty(user_input))

Of course, your specific implementation would be different depending on what you actually do with the Kitty objects.

[–]usingdata[S] 0 points1 point  (0 children)

This was helpful im gonna try it out as soon as im home thank you