0

Can someone help me pls

If I want to do an Operator with the first number in range(any thing) with the first number in range(anything) and so on But not the first number in first range with the second or third number in the another range

17th May 2022, 10:44 AM
ZIZO Abd alkawy
17 odpowiedzi
+ 2
first you declare inputs as a list and use index for operations eg. x[2]+y[1], to add the 3rd number in the 1st range and the 2nd number in the 2nd range ,try by your own and if it is hard i will send short code.
18th May 2022, 10:09 PM
MULUKEN ADDIS
MULUKEN ADDIS - avatar
+ 2
No bugs ,try again ,copy the code again
22nd May 2022, 7:28 PM
MULUKEN ADDIS
MULUKEN ADDIS - avatar
+ 1
ZIZO Abd alkawy, difficult to understand. please link your code here also provide an input / output sample
17th May 2022, 10:52 AM
Lothar
Lothar - avatar
+ 1
ZIZO Abd alkawy , this information is not enough to get useful help
17th May 2022, 10:59 AM
Lothar
Lothar - avatar
+ 1
ZIZO Abd alkawy , nested for loops do not run in parallel. to achieve this we can use zip() function: for ra1, ra2 in zip(range(1,3), range(1,3)): print(ra1 + ra2)
17th May 2022, 11:04 AM
Lothar
Lothar - avatar
+ 1
ZIZO Abd alkawy , you don't need to make a function, just use zip() which is a built-in function providedfrom python
17th May 2022, 11:08 AM
Lothar
Lothar - avatar
+ 1
I think I didn't take this lessonLothar Thanks for yourhelp
17th May 2022, 11:10 AM
ZIZO Abd alkawy
+ 1
MULUKEN ADDIS a =[range(1,5)] b =[ range(1,5)] for i in range(len(a)),range(len(b)): print(a[0] + b[0]) I tried this but the code didn't run
22nd May 2022, 4:13 PM
ZIZO Abd alkawy
+ 1
TRY THIS! ZIZO Abd alkawy n=int(input("how many numbers do you want to add in the range\n") ) d=[] sum=0 for i in range(n) : d.append(int(input("write 1 number,and press enter\n"))) print (d) n=int(input("how many numbers do you want to add in the second range\n") ) f=[] sum=0 for i in range(n) : f.append(int(input("write 1 number,and press enter\n"))) print('the sum of the second number in the first range and the first number in the secon range is:\n') print (d[1]+f[0]) """you can Change the indexes!!! d[1] is the second number in the range f[0] is the first number in the range""" """hit an upvote if it is help ful"""
22nd May 2022, 6:09 PM
MULUKEN ADDIS
MULUKEN ADDIS - avatar
+ 1
MULUKEN ADDIS there is a problem in line 8 or in my input I don't know Pls give me an input and check out the line 8 Thanks for your help
22nd May 2022, 6:20 PM
ZIZO Abd alkawy
0
Lothar I tried to use two for loop
17th May 2022, 10:54 AM
ZIZO Abd alkawy
17th May 2022, 10:58 AM
ZIZO Abd alkawy
0
It should be 2 4
17th May 2022, 10:59 AM
ZIZO Abd alkawy
0
Lothar just the fist number with the first number And the second with the second
17th May 2022, 11:02 AM
ZIZO Abd alkawy
0
U mean that I should make a function
17th May 2022, 11:06 AM
ZIZO Abd alkawy
0
I think I this function in the last unit in python core
17th May 2022, 11:13 AM
ZIZO Abd alkawy