Tuesday, 23 April 2024

STRING METHODES


# 1. Multiline String by using three quotes ''' or """

a = """ python is awesom,
pythone is easy,
pythone is fantastic"""
print(a)

# 2. String Are Array: Array Of bytes Represent Unicode Chracters. bar bracket [] used for access the element.

b = "hello, manan"
# In This Case I can Access The "nan" In His String So , I can Enter The Index Of nan is 9,10,11
print(b[9:12])

# 3. Looping Throug A String:

for c in "manan":
    print (c)

#  4. String Lenght : If We Want Find A Lenght Of String or Integir So

d = "manan"
e = (10,5)
print(len(d))
print(len(e))

#  5. Check String: If You Want Check Any Value In This String So

f = """Abdul Manan Javed Manj,
Abdul Hanan Javed Manj,
Abdul Rehman Javed Manj,
Abdul Wahab Javed Manj"""
# I can Find "Javed Manj" In f :
print("Javed Manj" in f)

# 6. Upper Case : If You Want Your String All Letters In Capital So

g = "Hello manan"
print(g.upper())

#  7. Lower Case : If You Want Your String All Letters In Lower So

h = "Hello HANAN"
print(h.lower())

# 8. Remove Space: If You Want Remove Space Between String So

i = "  manan, hanan,  "
print(i)
print(i.strip())

# 9. Replace String: If You Want Replace A One Letter In Different Letter So

j = "hanan"
# i cn replace M in h so
print(j)
print(j.replace("h","M"))

#  10. Split String: If You Want String In A List So

k = "manan, hanan, mani, wahab"
print(k)
print(k.split())

# 11. Concatonation String: Joining Different String In One String So

l = "Manan"
m = "Javed"
n = (l+" " +m)
print(n)
# if you want add a space in (l+m) so (l+" "+m)

No comments:

Post a Comment

MAKE A CALANDER

  # 1.  convert calander year and month. your choice month or year , print while True :   import calendar   year = int ( input ( "P...