Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

In need of help with Pyhton programming homework

+2 votes
asked May 14, 2020 by Alex (210 points)
Write a program that gives the symbol of the element and its number, when given an input of the full name of an element, all 118+ included.

1 Answer

+1 vote
answered Jun 7, 2020 by kailash Rathod (200 points)

first of all this a homework so I will not give you direct code I will help you with steps

1. Create a multi-dimensional list of Elements 

eg.  a = [['jhon',20,'male'],

2. Get input in the variable x or whatever

3. then use for loop to loop through the all the first element is which is a name in my case:


// this a loop for finding the element and printing its values

 for i in range(len(a)):

// here we are checking if the user input value matches or not if matches then print it 
                  if(x == a[i][0]):
                          print("Age: ",a[i][1]," Gender: ",a[i][2])

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.