Separate pair numbers and individual list
Write a function that receives a list of numbers and creates 2 lists for pair and individual numbers and prints on output
Example
myfun([1,2,3,4])
output:
[1,3]
[2,4]
Write a function that receives a list of numbers and creates 2 lists for pair and individual numbers and prints on output
Example
myfun([1,2,3,4])
output:
[1,3]
[2,4]
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
def adad_z_f(i): z=[] f=[] for num in numbers: if num%2==0: z.append(num) else: f.append(num) print(z,f) numbers=[1,2,3,4,5,6,7,8] adad_z_f(numbers)
def hazf(x): even = [] odd = [] for i in range(len(x)): if x[i]% 2 == 0: even.append(x[i]) else: odd.append(x[i]) return even, odd lists = [] even = [] odd = [] while True: x = int(input('adad ra vared konod ya jahat moshahede faghat 0 bezanid: ')) if x == 0 : even,odd = hazf(lists) print(f'even: {even}\nodd: {odd}') break lists.append(x)
def som_of_odds(): o=[] z=[] while 1: i=int(input(':')) if i==0: break if i%2==0: z.append(i) else: o.append(i) print(o,z) print(som_of_odds())
def print_eo_list(): eo_list = [] even_list = [] odd_list = [] while True: eo_nums = int(input("Enter a number Or enter zero(0) to exit: ")) eo_list.append(eo_nums) if eo_nums % 2 == 0: even_list.append(eo_nums) elif eo_nums % 2 != 0: odd_list.append(eo_nums) if eo_nums == 0: print(f"even and odd list => {eo_list}\neven list => {even_list}\nodd list => {odd_list}") break print_eo_list()
from os import system lst = [] odd = [] even = [] system('cls') while True: num = int(input('Enter number (0 = Exit) : ')) if num == 0: break lst.append(num) system('cls') for i in lst: if i%2 == 0: even.append(i) else: odd.append(i) lst.copy system('cls') print(f'odd number is {odd}') print(f'even number is {even}')
adad_zoj = [] adad_fard = [] while 1: number = int(input("please enter a number:" )) if number == 0: break elif number % 2 ==0: adad_zoj.append(number) else: adad_fard.append(number) print("adade zoj = ", adad_zoj) print("adade fard = ", adad_fard)
num_lst = [1, 2, 3, 4, 5, 6, 7, 8, 9] def odd_even(num_lst): odd_lst = [] even_lst = [] for item in num_lst: if item % 2 != 0: odd_lst.append(item) else: even_lst.append(item) print(f"odd numbers list=> {odd_lst}") print(f"even numbers list=> {even_lst}") odd_even(num_lst)
Submitting answers is currently unavailable.
Write a program that receives a number from the input and checks whether the number is segmented to 5. Tips: The numeric is on 5 segments that remain the remaining 5 zero
Write a program that receives a number of input and from that number to zero countdown and prints in the output
Write a function that receives a string and returns the number of letters: To solve this question, you should not use ready-made functions for example: get_len ('code-bezan.ir') # 13
Suppose we have the following 2 tables Users-> name, idbooks-> User_id, id, name 1- Write a query that shows user-related books at No. 2- Write a query to user names a ...
Write a program that receives a store product listing including name and product price and will continue until the amount of empty value for the product name is entered; Then the product name is displayed as a list ...
Write a function that receives infinite parameter and returns the average of numbers. If the parameter was non -extensive, it ignores it
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.