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 gets distance to meters and converts to kilometers and shows at the output tips: each km = 1000 m
Things need: The system administrator should be able to log in after entering the Admin username and password 12345 and add a new employee and define the username and password for each employee. The program must be informed ...
You must be logged in to access this section.
Login/Sign up 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.