Day 1: Find Array of Containing Longest String

preview_player
Показать описание
Join this channel to get access to perks:
This is the #100DaysOfCode Challenge. Day 1: Given an array of strings, return the array containing the longest string.
#python #machinelearning #datascience
Thanks for watching!
Рекомендации по теме
Комментарии
Автор

Hello! thanks for this challenges!! are great for those who are starting with Python. I follow this one, but i cant make RETURN to return me something, but if i replace return by print into the function y have the correct result. Hope you can help me!

def CadLarga(IniString):
#Busco el string mas largo analizando cada elemento y guardo el MAXIMO en la variable LARGO
Largo = max([len(st)for st in IniString])

#Creo una lista vacia - va a contener los resultados del analisis de string mas largo
Resultado = []

#Recorro la lista
for st in IniString:
#Voy comparando longitudes y si se cumple la condicion, ese elemento de la lista inicial, se AGREGA a la nueva lista
if Largo == len(st):
Resultado.append(st)
return Resultado #Cono RETURN coloco la nueva lista que contendria los elementos mas largos


IniString = ["aba", "aa", "ad", "vcd", "aba"]
CadLarga (IniString)

martinfaverio