This is a homework assignment. I just need a nudge.
I'm trying to create a loop in which the letters of a string will be removed when it is beyond a certain number.
Example:
Enter Your String: David
Enter Your Amount: 4
Returns: Davi
What I've made so far:
word = raw_input("Enter your string:")
amount = raw_input("Enter your amount:")
word_length = len(word)
if word_length > amount:
for i in range(word_length):
if s[i] > amount:
And that's just about as far as I've gotten. I'm not very sure as to which syntax I use to delete the letters that are in positions greater than word_length
.