[Solved] i cant seem to get it to print the Score out when i run quiz() it should show score out of 10 but it dose not

You are not printing the result instead you are returning it. So you could either print the function print(quiz()) or change the return for a print inside the quiz function. def quiz(): print(‘Welcome. This is a 10 question math quiz\n’) score = 0 for i in range(10): correct = askQuestion() if correct: score += 1 … Read more

[Solved] snake game: snake colliding with itself

In your code it looks as though you are checking if the head of the snake collide with itself, which will always return True. You need to individually check that the head of snake does not collide with any of it’s trailing segments: for segment in SnakeSegments[2:]: if pygame.sprite.collide_rect(h, segment): pass # collision detected, game-over … Read more

[Solved] How can I find a file in a directory [closed]

This isnt exactly what you asked for but it will get you started. import os #bring in the necessary library to access your specific os filename = raw_input(“Enter file: “) #get user input dirList = os.listdir(‘.’) #get the current directory listing if filename in dirList: #if the filename sought was in that dirlist…. print “file … Read more

[Solved] Using two return statements in a function (Python 2.7)

The function only prints out “Hello “. Then it returns, and its return value is “World.”. Returning means the function is finished and the interpreter continues wherever it was before the function was called, so whatever comes after the return is irrelevant. You called it as print doPrint(), which calls the function and prints whatever … Read more

[Solved] What representation of chat text data should I use for user classification? [closed]

You’re asking what ML representation you should use for user-classification of chat text. bag-of-words and word-vector are the main representations generally used in text-processing. However user-classification of chat is not the usual text-processing task, we look for telltale features indicative of a specific user. Here are some: character length, word length, sentence length of each … Read more

[Solved] Python: Unhashable error, lists

Two major issues: 1) You are storing the results in chos_items, then not doing anything with them. full_items, when you exit the while loop, contains “end” or “” print(“That would be, {}”.format(‘ ‘.join([items[int(item)] for item in chos_items]))) Will give you a list of all the items chosen, but it won’t give how many, as you … Read more

[Solved] Count consecutive spaces(&nbsp) at the start of the string in Python [closed]

The most pythonic way to do this is the following: def count_start_spaces(s): return len(s) – len(s.lstrip()) Given the following input: strings = [“Test1 False (String 1)”,” Test2 False (String 2)”,” Test3 False (String 3)”] list(map(count_start_space, strings)) # output: [0, 4, 8] 2 solved Count consecutive spaces(&nbsp) at the start of the string in Python [closed]