TÓPICO

Runtime Error

Ashok perguntou 1 year ago

why it's getting runtime error

import math while True: string = input()

if string == "":
    break

total_length = 0
total_word = 0
length = 0
valid_word = True
for character in string:
    if character == ' ':
        if length > 0 and valid_word:
            total_length += length
            total_word += 1
        length = 0
        valid_word = True
        continue

    ascii_value = ord(character)
    if ascii_value >= 48 and ascii_value <= 57:
        valid_word = False
        continue

    if (ascii_value <= 122 and ascii_value >= 97) or (ascii_value <= 90 and ascii_value >= 90):
        length += 1
    else:
        valid_word = False
        length += 1
if length > 0 and valid_word:
    total_length += length
    total_word += 1
    length = 0

if total_length > 0 and total_word > 0:
    avg = math.floor(total_length / total_word)
else:
    avg = 0

if avg <= 3:
    print(250)
elif avg <= 5:
    print(500)
else:
    print(1000)

Este tópico foi resolvido e não pode receber novas respostas.