You are given an array strarr
of strings and an integer k
. Your task is to return the first longest string consisting of k consecutive strings taken in the array.
Example:
longest_consec([“zone”, “abigail”, “theta”, “form”, “libe”, “zas”, “theta”, “abigail”], 2) --> “abigailtheta”
n being the length of the string array, if n = 0
or k > n
or k <= 0
return “”.
Note
`
`> def longest_consec(strarr, k):
while(k>0):
longest_array=[]
string_s=str(input("enter some comma separated value"))
longest_array.append(string_s)
k=k+1
for a in range(0,k):
n=len(longest_consec[a])
if(n>k or k<=0):
return longest_consec[a]
break
`
the code of mine is above.i have to check the longest string and return it.but
the error shows
Traceback (most recent call last):
File “main.py”, line 8, in
testing(longest_consec([“zone”, “abigail”, “theta”, “form”, “libe”, “zas”], 2), “abigailtheta”)
File “/home/codewarrior/solution.py”, line 4, in longest_consec
string_s=str(input(“enter some comma separated value”))
EOFError: EOF when reading a line
please help me.