def create_category(info): li = info.split() if len(li) == 2: if is_numeric(li[1]) == True: li[2] = float(l[2]) else: return -1 else: return -2 """ Given a string `info`, which is supposed to contain the category name and its percentage, return a two-element list, which contains this information stored as a string and a float respectively. Calls is_numeric() to verify that the percentage is a numeric value (int or float). Stores the percentage as a float (not as a string). E.g., if the input is "Quiz 25", the function returns a list: ["Quiz", 25.0] If splitting the `info` string does not result in a two-element list, then return -2. If the last input value (the percentage) in `info` is not numeric (int or float), does not update the list and returns -1 instead. """ debug
def create_category(info):
li = info.split()
if len(li) == 2:
if is_numeric(li[1]) == True:
li[2] = float(l[2])
else:
return -1
else:
return -2
"""
Given a string `info`, which is supposed to
contain the category name and its percentage,
return a two-element list, which contains this
information stored as a string and a float
respectively.
Calls is_numeric() to verify
that the percentage is a numeric value (int or float).
Stores the percentage as a float (not as a string).
E.g., if the input is "Quiz 25", the function
returns a list: ["Quiz", 25.0]
If splitting the `info` string does not result
in a two-element list, then return -2.
If the last input value (the percentage) in `info`
is not numeric (int or float), does not update the
list and returns -1 instead.
"""
debug

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









