The below code prints none at the end

0 votes
def twoSum(nums, target):
    if len(nums) <= 1:
        return False
    for i in range(len(nums)):
        print(i)

var1 = [2, 7, 11, 15]
var2 = 9
print(twoSum(var1, var2))


problem: works but prints none at the end. anyone know? i tried to change len(nums) in the for i in range line to a number like 1 and still?

Nov 15, 2020 in Python by Rajiv
• 8,870 points
495 views

1 answer to this question.

0 votes

the code after return does not execute. Your IDE should have shown you a warning about it.

Because you're printing the value of twoSum() which doesn't have one, it returns nothing.

answered Nov 15, 2020 by Gitika
• 65,770 points

Related Questions In Python

0 votes
1 answer

How to solve indentation in the below code?

Python does not use brackets, it uses ...READ MORE

answered Feb 9, 2019 in Python by Omkar
• 69,220 points
676 views
0 votes
1 answer

i write this python to read dataset into panda data frame but im getting NameError: name 'true' is not defined. Below is the code:

change  def parse(path):   g = gz ...READ MORE

answered Mar 15, 2020 in Python by Abhishek Shingadiya
3,646 views
0 votes
2 answers

Help me solve the code

The fetchone() method fetches the result of ...READ MORE

answered Jan 9, 2019 in Python by Omkar
• 69,220 points
1,010 views
0 votes
2 answers

How to add a certain time delay to the code using Python?

You can use time.sleep(duration in second) READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
1,207 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,042 views
0 votes
1 answer

What will be the output of below code and why? x=[1,2,3,4,5] print(x.insert(2,3))

If you write x.insert(2,3) and then print x ...READ MORE

answered Oct 14, 2020 in Python by Gitika
• 65,770 points
4,349 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP