Python Forum
Last caracter of a string truncated issue when working from the end of the string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Last caracter of a string truncated issue when working from the end of the string
#1
Hello, can someone please explain why when I select a range starting from the end of a string it truncates the last character?
I can work from the front end as variable dst will always be the same length but when faced with an unknown string length it would be an issue

dst = (r"C:\Users\tekno\Documents\Client Drawings\AAA001")
dwg_name = (dst[-7:-1])
print(dst)
print(dwg_name)
print(dst[40:47])
print(dst[-7:-1])
print(dst[-1])
Output:
C:\Users\tekno\Documents\Client Drawings\AAA001 \AAA00 \AAA001 \AAA00 1
Reply


Messages In This Thread
Last caracter of a string truncated issue when working from the end of the string - by Teknohead23 - Oct-03-2021, 12:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use or raw string on regular expressions Zaya_pool 5 256 May-09-2024, 06:10 PM
Last Post: Zaya_pool
  How do I parse the string? anna17 4 404 Apr-10-2024, 10:26 AM
Last Post: DeaD_EyE
  remove gilberishs from a "string" kucingkembar 2 303 Mar-15-2024, 08:51 AM
Last Post: kucingkembar
  Matching string from a file tester_V 5 504 Mar-05-2024, 05:46 AM
Last Post: Danishhafeez
  Python3 string slicing Luchano55 4 669 Feb-17-2024, 09:40 AM
Last Post: Pedroski55
  Retrieve word from string knob 4 538 Jan-22-2024, 06:40 PM
Last Post: Pedroski55
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 1,056 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  Virtual Env changing mysql connection string in python Fredesetes 0 409 Dec-20-2023, 04:06 PM
Last Post: Fredesetes
  Comparing Dataframe to String? RockBlok 2 444 Nov-24-2023, 04:55 PM
Last Post: RockBlok
  Sample random, unique string pairs from a list without repetitions walterwhite 1 502 Nov-19-2023, 10:07 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020