Every tutorial I’ve seen online all talk about strings that are already in the code. I’m a beginner trying to make a simple Spanish verb conjugator. I’m trying to make it so that when the user enters an infinitive verb (ex: caminar) the last two letters are taken off so that the verb can be conjugated later on.
Not much but here’s what I’ve got so far:
original = input (‘Enter an infinitive verb:’)
return original[ : -2]
Hi @redpotter - welcome to the forum.
You’re certainly on the right lines, but you’ve made a few mistakes.
Here’s what I think your code should look like, correctly formatted:
original = input("Enter an infinitive verb: ")
Let’s start at the top and work down…
>>> Enter an infinitive verb: test
Traceback (most recent call last):
File "verb.py", line 7, in <module>
File "verb.py", line 3, in Choose_Option
AttributeError: 'builtin_function_or_method' object has no attribute 'endswith'
The interpreter doesn’t like
input is a built-in function. You should be calling the
.endswith() method on a string variable. Can you see how to change this to fix the error?
If I fix that error, and try again, then the program runs to completion but I get no output from the console. You have a bit more work to do, I think.
Great thank you. I’ll have to figure out how to complete the output from the console now.
OK so I have no errors now but the console still won’t output the verb with the last 2 letters taken off which is what I’m trying to get
Ok. Can you post the updated program, as you now have it?
When you’re posting the code, please make sure to use the code formatting button ( </> ) in the editor.
The </> button will insert a block into your post, like this:
Paste the code in the middle, where it says
type or paste code here.
You’ll end up with code like this:
Here it is:
original_verb = input ("Enter an infinitive verb: ")
original_verb = Verb_Choice()