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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:00
Ahorse is how much percent more powerful than a pony
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
Me if you do then you get 10 points and brainliest
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
Anew author is in the process of negotiating a contract for a new romance novel. the publisher is offering three options. in the first option, the author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published. in the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold. in the third option, the author is paid 10% of the net price for the first 4,000 copies sold, and 14% of the net price for the copies sold over 4,000. the author has some idea about the number of copies that will be sold and would like to have an estimate of the royal- ties generated under each option. write a program that prompts the author to enter the net price of each copy of the novel and the estimated number of copies that will be sold. the program then outputs he royalties under each option and the best option the author could choose. (use appropriate named constants to store the special values such as royalty rates and fixed royalties.
Answers: 1
question
Computers and Technology, 24.06.2019 18:00
Explain the circumstances for which the interquartile range is the preferred measure of dispersion. what is an advantage that the standard deviation has over the interquartile range? choose the correct answer below. a. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it increases as the dispersion of the data increases. b. the interquartile range is preferred when the data are not skewed or no have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. c. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it is resistant to extreme values. d. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it is resistant to extreme values. e. the interquartile range is preferred when the data are skewed or have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. f. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it increases as the dispersion of the data increases.
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
question
Mathematics, 30.03.2020 20:32
question
Mathematics, 30.03.2020 20:32
question
Mathematics, 30.03.2020 20:32
question
Mathematics, 30.03.2020 20:32
question
Mathematics, 30.03.2020 20:32
Questions on the website: 13722363