+ 1
Numbers=[1,3,4,6,81,80,100,95]
Assert==[odd,odd,even,even,odd,five even,five even,five odd]
12 Answers
+ 3
SRINATH CHOWDARY you should use if/elif with four cases as stated in your question:
1. (Number%5==0) and (Number%2==0) append five even
2. (Number%5==0) and (Number%2!=0) append five odd
3. Number%2==0 append even
4.append odd
+ 3
SRINATH CHOWDARY This is my solution to the problem.
Please review and tell me if this is what you really intended. Check it out here
https://code.sololearn.com/c45TlyL5UmhS/?ref=app
+ 2
What is your attempt? Can you show us what you've done so far?
+ 2
I think you should test the 5 before :
for number in numbers:
new_element = ""
if number % 5 == 0:
new_element += "five"
if number % 2 == 0:
new_element += "even"
else:
new_element += "odd"
+ 1
Answer for this question please
+ 1
Just u can hang for 5 mins
+ 1
my_list[ ]
for number in numbers:
if %2==0:
new_element = 'even'
elif %5==0:
new_element = 'five odd'
elif %5 ==0:
new element = 'five even'
else:
new_element ='odd'
my_list.append=(new_element)
print(my_list)
And the question has some rules to
1.If the number is a multiple of five and odd, the string should be 'five odd'.
2.If the number is multiple of five and even, the string should be 'five even'.
3.If the number is odd string is 'odd'
4.If the number is even string is 'even'.
+ 1
SRINATH CHOWDARY "Answer for this question please"
You didn't post any question.
+ 1
SRINATH CHOWDARY I see.
In that case, refer to the code posted by Yusuf Shuaib Olalekan, it looks correct :)
+ 1
Numbers=[1,3,4,6,81,80,100,95]
def fun(n):
if n % 5:
return 'odd' if n & 1 else 'even'
else:
return 'five odd' if n & 1 else 'five even'
rm = list(map(fun, Numbers)) # using map
print(rm)
rc = [fun(i) for i in Numbers] # using list comprehension
print(rc)
* I didn't understand what you mean by this line:
Assert==[odd,odd,even,even,odd,five even,five even,five odd']
0
Gregor Dietrich
Numbers=[1,3,4,6,81,80,100,95]
Assert==[odd,odd,even,even,odd,five even,five even,five odd']
And the question has some rules to
1.If the number is a multiple of five and odd, the string should be 'five odd'.
2.If the number is multiple of five and even, the string should be 'five even'.
3.If the number is odd string is 'odd'
4.If the number is even string is 'even'.
0
Gregor Dietrich
Yes but we can do in some sort of easy way



