Lecture 002 -- Homework #238
Replies: 3 comments
-
Hey @Elltawariel You right in filtering out the molecules = [
'CCCC=C',
'CCCC',
'CC#CCC#C',
'CCCCCCCCCC',
'CCC([H])([H])([H])'
]
pure_hydrocarbons = [ molecule for molecule in molecules if '=' not in molecule and '#' not in molecule] The next two you are right there in either appending the (O)=O at the end of the string. carboxylic_acid = '(O)=O'
carboxylic_acids = [hydrocarbon + carboxylic_acid for hydrocarbon in pure_hydrocarbons if '([H])' not in hydrocarbon ] The last string is a little complicated because if you add the carboxylic_acid to the carbon you will get a string like this:
Which looks like this: And that can't be right. Our target string would look something like this:
The goal here would be then to replace the string. Can you think of what to do to achieve that? Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
Hi! So yeah, hydrocarbons == alkanes only, which is an unclear point. For me, hydrocarbons are the structures, that don't have other atoms but C an H. But what if there is only 1 ([H]) ? Thanks |
Beta Was this translation helpful? Give feedback.
-
That is totally right. Sometimes I denote the alkene and alkyne as a functional group that is different from alkanes. This might be my own confusion on the words. So be clever about it. One thing you could do is
Try writing that algorithm in python. Let me know and I can edit your code/help. |
Beta Was this translation helpful? Give feedback.
-
Hello all.
I am struggling with homework in lecture 2. Task is a little bit unclear to me.
This is easy if I create carboxylic acid by adding COOH group at the end.
But if I need to modify the last or first carbon to make COOH, then it is somewhat tricky.
Firstly, I need to check if the last carbon is not =C or #C. I can do it by checking [1] or [-2],. But then in the case of (H), it doesn't work.
Do I overthink this task and actually what is asked is to add carboxylic acid to the end of the chain?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions