[Solved] What are the Similarities between Dictionary and Array data types? [closed]

A dictionary maps strings to values. An array maps integers to values. That is about it! So, seriously: in the end, both data structures map a “key set” to values. For dictionaries, the keys can of (almost) arbitrary type, without any constraint on them (besides being “hash able”). Whereas an array maps a consecutive range … Read more

[Solved] Why doesn’t if, elif or else work with .lower() in Python? [closed]

You need to call the method: month.lower() == ‘march’ The method is an object too, and without calling it you are comparing that method with a string. They’ll never be equal: >>> month=”January” >>> month.lower <built-in method lower of str object at 0x100760c30> >>> month.lower == ‘January’ False >>> month.lower == ‘january’ False >>> month.lower() … Read more

[Solved] How do I create a scoring system in Python? [closed]

def QuestionSet1(): print(“Challenge level 1 has being selected.”) print(“Can you translate these words into french?”) a=input(‘Q1. Hello! :’) score = 0 if ‘bonjour’ in a.lower(): score = score + 1 print(‘Correct!’) else: print(‘Wrong! ‘+’Its Bonjour’) print(‘You have finished and scored’, score, ‘out of 10’) You would need make a reference to score before you give … Read more

[Solved] How to avoid ‘1’ when incoming is none

Can you try the following: req_keys = [‘col1’, ‘col2’, ‘col3’, ‘col4’] all_list = [incoming[i] for i in req_keys] all_list = [i for i in all_list if i] print(‘1’.join(all_list)) Example: incoming = {} incoming[‘col1’] = ‘a’ incoming[‘col2’] = None incoming[‘col3’] = ‘c’ incoming[‘col4’] = None Output: a1c Another Example: incoming = {} incoming[‘col1’] = ‘a’ incoming[‘col2’] … Read more

[Solved] Need Help converting to python 2.7

You might want to try future statements. Basically, keep the code the way it is, and backport features to 2.7. I already see the print statements causing problems, so at the top just add from __future__ import print_statement. This will cause Python 2.7 to read print as if it were running in 3.x. Running the … Read more