subject

What is wrong with this piece of code? I am trying to create a list given specific strings and an input, then find the largest word and return/print it. def largest(words):

Length = 0
Word = ""

largest_word = ""
num_Words = len(words)

for x in range(0, num_Words, 1):
largest_word = words[x]
largest_length = len(largest_word)
if (largest_length >= Length):
largest_length = Length
largest_word = Word

return largest_word

user_pet = input("Enter a pet: ")
y = ["cat", "dog", "hamster", user_pet]
largest_petname = largest(y)
print(largest_petname)

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 08:30, Bradgarner772
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, magicalpenguin48
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, codycollier
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
image
Computers and Technology, 24.06.2019 17:30, leenzazou98241
What is the next step if your volume does not work on computer
Answers: 2
You know the right answer?
What is wrong with this piece of code? I am trying to create a list given specific strings and an in...

Questions in other subjects:

Konu
Mathematics, 25.03.2020 11:36
Konu
English, 25.03.2020 11:40
Konu
Mathematics, 25.03.2020 11:44