ezmiguel Posted October 27, 2022 Share Posted October 27, 2022 Tenho as duas listas a = [0, 1, 2, 3, 4, 5, 6] b= [1, 0, 0, 1, 0, 1, 0] (ambas sempre terão mesmo número de elementos) Como faço para organizá-las em um dicionário em que os elementos de a sejam os índices e os elementos de b sejam os valores em sua respectiva ordem? c = {0: 1, 1: 0, 2: 0, 3: 1, 4: 0, 5: 1, 6: 0} Link to comment Share on other sites More sharing options...
ezmiguel Posted October 27, 2022 Author Share Posted October 27, 2022 c = dict() for i in a: c[i] = b[i] 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now