+ 1

Python Code - Linear Search

I am able to run this code perfectly fine on the IDLE which is downloaded in my laptop but the same won't run here in the code playground . Why so ? CODE: def Lsearch(ar,item): i=0 while i<len(ar) and ar[i]!=item: i+=1 if i<len(ar): return i else: return False b=[2,7,5,3,9,4] Lsearch(b,3) P.S : I have the screenshots of the same . Don't know how to upload it.

31st Oct 2018, 2:33 PM
Sreyashi Bhattacharjee
4 Respuestas
+ 3
Hi Sreyashi Bhattacharjee! I tried running your code on Sololearn's Code Playground, and it worked quite fine! What did it say when you ran it? Your code doesn't have any output, so I had modified the last line to print(Lsearch(b, 3)) P.S., uploading screenshots/images is tricky. You can post it in your own feed or upload it to Imgur/Dropbox/Google Drive and share a link here. But I don't think that would be necessary in this case.
31st Oct 2018, 2:53 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
Make a code and publish here the link, making it easier to debug for who reads
31st Oct 2018, 2:47 PM
Etabeta1🇮🇹
Etabeta1🇮🇹 - avatar
+ 1
It was saying "No output" Thank you for the corrections.
31st Oct 2018, 3:16 PM
Sreyashi Bhattacharjee
+ 1
Oh, okay! Happy to help! 😊
31st Oct 2018, 3:20 PM
Kishalaya Saha
Kishalaya Saha - avatar