0

How do i fix this code. Im trying to pull an item from a list. Have that item mean a word, and pull it by using user input

abc=[1, 2, 3] abc.index([0]) = apple abc.index([1]) = bananna abc.index([2]) = cat if (int(input(''))) = 1 print abc.index(1) elif (int(input(''))) = 0 print abc.index(0)

17th Oct 2018, 4:15 PM
pixel strength
pixel strength - avatar
11 Answers
+ 2
Index doesn't work as you think. This is an example of using it: https://code.sololearn.com/cHsz7VWS9k2I
17th Oct 2018, 7:41 PM
John Wells
John Wells - avatar
+ 3
I thought it meant as a # from an array to be pulled
17th Oct 2018, 9:18 PM
pixel strength
pixel strength - avatar
+ 2
i am looking for the algorithme to revert binaires. from 01111111 to 10000000
17th Oct 2018, 10:53 PM
Christopher D. Museme
Christopher D. Museme - avatar
+ 1
I'm trying to make a thing for my science class and write. if user input h then it'll pull a variable from list and make it tell info about hydrogen. I think I can make this work tho. if I do your code but add 1 == he == helium and then put print (he) and then put in another list is he info and it'll print helium 2 protons 2 electrons and ect. does that make sense or should I not try that and frusterate myself?
17th Oct 2018, 9:37 PM
pixel strength
pixel strength - avatar
+ 1
Do you know classes as yet? They could store all of the information as a single entity in your list. You could search them with atomic number (integer), chemical name (3 or more letters), or chemical symbol (1 or 2 letters).
17th Oct 2018, 9:52 PM
John Wells
John Wells - avatar
+ 1
not yet. still working towards my certificate. if you look at my python code I posted I did I lowerlvl version of that. not indexing and more focused on orbitals. I'm a highschool freshman and I want to get into this as a career so I thought I'd try to start early
17th Oct 2018, 9:55 PM
pixel strength
pixel strength - avatar
+ 1
You definitely did not start early. My son started programming at 8. It was his plan to do college for it next year. But, decided to do automotive first followed by computers. He wants to fully computerize cars.
17th Oct 2018, 10:00 PM
John Wells
John Wells - avatar
+ 1
wow. I meant like nearly any of my friends in school are doing anything to work for their career. I've recently started this and I want to go more on the informative/game developer side. I was just letting you know and thx for the help. I hope some day I can be as good as you or your son.
17th Oct 2018, 10:05 PM
pixel strength
pixel strength - avatar
+ 1
also he's had you to guide him and this app is all I have for me.
17th Oct 2018, 10:09 PM
pixel strength
pixel strength - avatar
+ 1
I am willing to help. Tag me in a code comment anytime you got a question.
17th Oct 2018, 10:16 PM
John Wells
John Wells - avatar
+ 1
Christopher D. Museme if you just want to flop bits: int bits = 0x84218421; bits ^= 0xffffffff; yields: 0x7bde7bde
17th Oct 2018, 11:07 PM
John Wells
John Wells - avatar