Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please can anybody help me, i want to create a adjacency list based on user input. so for the following user input
Python
C-C-C-C
  |       | 
  C C
  | 
  C
it would output

Python
carbongraph = {"1":["2"], "2":["1","3","5"], "3":["2","4","6"], "4" :["3"], "5":["2","7"], "6":["3"], "7":["5"]}

as it reads from left to right, top to bottom as if reading a book

just tell me how to Number the C's from 1 to 7 rom left to right, top to bottom as if reading a book, i will figure the rest out myself.

somebody please answer me i have been stuck for days.

What I have tried:

I have tried using enumerate but i just cant get past how to get round it.
Posted
Updated 31-Mar-19 6:22am

1 solution

1-2-3-4
  | |
  5 6
  |
  7
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900