[Solved] Python – Trying to make a Random String Generator

Your code is mostly unsalvageable but I’ll go through it and explain all the issues I’ve encountered with it. You also didn’t indent your code properly in your question so I’ve made some assumptions on that front. Addressing Code Issues Alphabet generation Alphabet = [“a”,”b”,”c”,”d”,”e”,”f”,”g”,”h”,”i”,”j”,”k”,”l”,”m”,”n”,”o”,”p”,”q”,”r”,”s”,”t”,”u”,”v”,”w”,”x”,”y”,”z”]` Alphabet2 = [“A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”]` These could be more succinctly expressed as: … Read more

[Solved] Use the method is_vowel

You can use char in “aeiouAEIOU” to determine if a character is a vowel, and use a list comprehension to produce a list containing only vowels, and find the number of vowels in the input string by finding the length of this list. string=raw_input() numOfVowels=len([char for char in string if char in “aeiouAEIOU”]) print(numOfVowels) Input: … Read more

[Solved] How do I make a function in python which takes a list of integers as an input and outputs smaller lists with only two values?

If you only want groups of two (as opposed to groups of n), then you can hardcode n=2 and use a list comprehension to return a list of lists. This will also create a group of one at the end of the list if the length of the list is odd: some_list = [‘a’,’b’,’c’,’d’,’e’] [some_list[i:i+2] … Read more

[Solved] Sum of string elements of python list [closed]

CAUTIOUS Assuming a, b, and c are variables. You can use locals() function to get all the varibales in the local scope. Calling locals() function returns a dict, where name of the varibale is key and data stored in the variable is value. I would highly recommend not to use this approach. Rather store, a, … Read more

[Solved] Indentation error basic program [closed]

You should indent your main function with spaces or tabs. (4 spaces is recommanded) Like this: def main() num=input() # rest of your main code main() I saw you already did this for if/else, you should also do it for functions. I recommend you take a beginner python course like the one of codecademy. solved … Read more