Odpowiedź:
def get_percentage(value, text):
count = text.count(value)
total = len(text)
percentage = 100 * count / total
return percentageprint(get_percentage("A", "ABCD")) - zwraca 25.0
print(get_percentage("X", "XYZ")) - zwraca 33.33333333333333
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Odpowiedź:
def get_percentage(value, text):
count = text.count(value)
total = len(text)
percentage = 100 * count / total
return percentage
print(get_percentage("A", "ABCD")) - zwraca 25.0
print(get_percentage("X", "XYZ")) - zwraca 33.33333333333333