Please have a look, I am unable to submit the code performed for even numbers.
It should “print” not “return”.
it is not working with Print. PFA the error
NameError Traceback (most recent call last)
in
4 enum.append(n)
5 print (‘enum’)
----> 6 print(print_even(5))
in print_even(n)
2 for n in range (0,n):
3 if n % 2 == 0:
----> 4 enum.append(n)
5 print (‘enum’)
6 print(print_even(5))
NameError: name ‘enum’ is not defined
Hi, Suman.
Please read the instructions again.
It is told just to print the even number not to use a list for that. Using an extra list data structure is increasing the space complexity of the program.
Try just to print it that is all.
if i%2==0:
print(i)
All the best!
Thank you
It is working fine.
I am trying to solve Q. 6 for Churn Emails project but code is not working. Please help me with this:
Here is my code:
def find_email_sent_day():
fhand = open(’/cxldata/datasets/project/mbox-short.txt’)
days_count={}
for line in fhand:
line = line.rstrip()
if line.startswith(‘From:’):
days=line.split(" ")[2]
if days not in days_count:
days_count[days]= 1
else:
days_count[days]= days_count[days]+1
return days_count
find_email_sent_day()
And the Error is showing:
IndexError Traceback (most recent call last)
in
11 days_count[days]= days_count[days]+1
12 return days_count
—> 13 find_email_sent_day()
in find_email_sent_day()
5 line = line.rstrip()
6 if line.startswith(‘From:’):
----> 7 days=line.split(" ")[2]
8 if days not in days_count:
9 days_count[days]= 1
IndexError: list index out of range