How can I remove first n characters from a python string



knull

Basic
Joined
13.07.21
Messages
3
Reaction score
0
Points
0
How do I compose a program to eliminate characters from a string beginning from zero up to n and return another string.

The n must be less than the length of the string.

This is my assignment question, I need help on this.

Thanks!
 

hindsighttt

Basic
Joined
26.08.23
Messages
66
Reaction score
21
Points
8
well you can make n a variable and then you do some basic string slicing.

for example you should do this

Python:
cc_num = "5181161225222504" #has to be a string, if not you can convert it using 'str(variable/fl/int)'

n = int(cc_num.len() - 11) #gets the length of the string and removes 11 from it so it only reads the first 6 numbers

sliced_num = cc_num[0:n] # first number is inclusive and the second is exclusive

print(f'your bind is {sliced_num}')
 
Top Bottom