7th Feb 2018, 6:59 PM
Raphael Shay
Raphael Shay - avatar
3 Respuestas
+ 2
Calculators are used for math instead of language/words. You don't have a list, you're using an array. If you're specifying the indices of them, then you'll use string[index] for arrays and list.index() for items of a list. Indices need to be int. Not to mention that you don't subtract numbers from words; that's not math. What exactly is your goal in the code? I'm more than happy to help you out with it.
7th Feb 2018, 7:16 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 2
After reading your code more, I -think- you're trying to remove the letter at the particular index right? Basically, take the length of the string, divide it in half, and remove the letter that's at that index? This may be helpful, replace your print statement at bottom with this: print(a.replace(a[int(i)], "")) ^That's going to look at the string, grab the index your want and then remove the letter in that dex. In your example, the output would be "wod"
7th Feb 2018, 7:20 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 2
inputs = [] i = input() x = i.lower() t = len(x) def length(): if len(x) % 2 == 0: print("The word is '" + str(x) + "'.") print(x.replace(x[int(i)], "")) else: print("The word is invalid, please enter an even lengthed word.") length() #Why does this not work like you told me?
8th Feb 2018, 6:11 AM
Raphael Shay
Raphael Shay - avatar