+ 5

Python Problem: reset an element of a list by two other elements

I came across this problem when trying a challange: Given a list [4,1 ] reset the first element of the list by all members of the list [3,1] --> [3,1,1] after by the list[2,2] --> [2,2,1] did not yet find an elegant solution

24th Jan 2018, 5:15 PM
Oma Falk
Oma Falk - avatar
5 ответов
+ 2
I don't know if this looks elegant. This came natural. a = [4, 1] b = [2, 2] c = [3, 5] print(b+a[1:]) print(c+a[1:])
25th Jan 2018, 8:13 PM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
+ 6
given a List A [4,1] given a List B [2,2] given a List C [1,3] from List A reset first Element by all Elements of List B --> [2,2,1] then from original List A reset first Element by all Elements of List C --> [1,3,1] looking for an elegant solution.
25th Jan 2018, 2:04 PM
Oma Falk
Oma Falk - avatar
+ 5
yes it is!
25th Jan 2018, 8:15 PM
Oma Falk
Oma Falk - avatar
+ 3
@ravi it helped me a lot . thank you
26th Jan 2018, 7:42 AM
Oma Falk
Oma Falk - avatar
+ 1
I did not quite understand your question. How do you reset the first element with all members?
25th Jan 2018, 11:06 AM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar