given_items = ["one", "two", 3, 4, "five", ["six", "seven", "eight"]]
#Write a program that iterates through the items in the
#given list. For each item, you should attempt to iterate
#through the item and print each character seperately.
#
#If this second part fails, print "Not iterable" -- but
#even if the second part fails, you should still go on
#to the next item in the list.
#
#Hint: Although we'll cover lists more in Unit 4, all
#you need to know right now is that this syntax will run
#a loop over a list, a string, or any other iterable
#type of information:
#
# for item in given_items:
#
#To iterate over the items in 'item', you can do the
#same thing: for subitem in item:
#
#Start out by building the nested for-each loops that
#you'll need. Then, identify where the error is
#occurring to figure out where to put the try-except
#structure.
#
#This one's tricky, but you can do it!
#Add your code here!
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
# Take the items in the list
given_items = ["one", "two", 3, 4, "five", ["six", "seven", "eight"]]
# Start loop through the list
for item in given_items:
# Start looping through each item
# Use try-except here
try:
for subitem in item:
for sub_subitem in subitem:
# Print first character
print(sub_subitem[0])
except TypeError:
# Type Error is there
print('Not Iterable')
=============


given_items = ["one", "two", 3, 4, "five", ["six", "seven", "eight"]] #Write a program that iterates through...
I need to write a Python Program for the following question. Link for tallest mountains: https://en.wikipedia.org/wiki/List_of_mountains_by_elevation Use top 10 tallest mountains. Part One Wikipedia has a list of the tallest mountains in the world each mountain's elevation. Pick 10 mountains from this list. Create a dictionary with the mountain names as keys, and the elevations as values. Print out just the mountains' names, by looping through the keys of your dictionary. Print out just the mountains' elevations, by looping through...
Instructions We're going to create a program which will allow the user to add values to a list, print the values, and print the sum of all the values. Part of this program will be a simple user interface. 1. In the Program class, add a static list of doubles: private statie List<double> _values new List<double>) this is the list of doubles well be working with in the program. 2. Add ReadInteger (string prompt) , and ReadDouble(string prompt) to the...
Piggy back on the programming project one you completed in module 3. You will use some of those concepts here again. We will be building this project inside out, start individual quiz and use a for loop to repeat it three times for three students. In this program you will be required to write a python program that generates math quizzes for students in second grade. Your program should do the following Ask the student for their name Provide 3...
Part I - Functions Write a program to do the following: • . Create two separate lists: ["Female", "M", 1, 4, "Mail", 0, "F"] o [-23,1,35,52,23,0,1000] For each element in the first list, replace each element using the following rules: o Change the value to Female if the element is Female, F, or 1 o Change the value to Male if the element is Male, M, or 0 o Otherwise, change it to "Undefined" For each number in the second...
Need help solving this qestion related to object and item classes involving arrays in PYTHON. Classes and Object - Inventory Item as Object In this assignment the idea is to use an Item class to capture what you need for recording and displaying the details of an order from an online store like Amazon. This is a Class and Object assignment. For the assignment you must define and implement the Item class so that the code shown immediately below can...
*Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...
ONE THROUGH FIVE PARTS ALREADY ANSWERED, NEED PARTS SIX AND SEVEN PLEASE Question 1) Please answer each of the questions using the data as provided in the most optimal manner. Do Exercise #12, part on page 317 of the Freund et al. (2010) textbook. The question is reproduced below. The data is also provided online Provide the estimated standard error for the estimated mean of the WA medium. Provide the 95% regular confidence interval on the mean difference between the WA and RDA...
I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...
For part one of this assignment, write a program (parse.c) that contains a function to parse a single line of input and and prints out the individual tokens. Part 1 - Single Line Parser For part one of this assignment, you will need to learn how to do some parsing (or more accurately--lexing a line, you do not have to check for correctness). You have previously done some parsing with the cycle count tool perhaps using functions such as strcmp....
Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...