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
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.
+ 2
No bugs ,try again ,copy the code again
+ 1
ZIZO Abd alkawy,
difficult to understand.
please link your code here
also provide an input / output sample
+ 1
ZIZO Abd alkawy ,
this information is not enough to get useful help
+ 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)
+ 1
ZIZO Abd alkawy ,
you don't need to make a function, just use zip() which is a built-in function providedfrom python
+ 1
I think I didn't take this lessonLothar
Thanks for yourhelp
+ 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
+ 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"""
+ 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
0
Lothar I tried to use two for loop
0
It should be
2
4
0
Lothar just the fist number with the first number
And the second with the second
0
U mean that I should make a function
0
I think I this function in the last unit in python core