text = 'bitcoin take over the world maybe who knows'
def find_short(text):
text_copy = text
numbers = []
for index, elem in enumerate(text_copy):
if elem != ' ':
continue
numbers += [index + 1]
text_copy = text_copy[index + 1:]
numbers += [len(text_copy)]
numbers.sort()
return numbers[0]
def find_short(text):
num_of_let=0
min_numb = len(text)
for elem in text:
if elem == ' ':
if num_of_let < min_numb:
min_numb=num_of_let
num_of_let=0
else:
num_of_let+=1
return min_numb
text = 'bitcoin take over the world maybe who knows'
find_short(text)
def find_short(text):
num_of_let=0
word=[]
min_numb = len(text)
for elem in text:
if elem == ' ':
if num_of_let < min_numb:
min_numb=num_of_let
min_word=''.join(word)
num_of_let=0
word=[]
else:
word=word+list(elem)
num_of_let+=1
return min_numb,min_word