Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) [Clang 6.0 (clang-600.0.57)] on darwin Type "copyright", "credits" or "license()" for more information. >>> s = "Hello, how are you?" >>> s 'Hello, how are you?' >>> len(s) 19 >>> s[0] 'H' >>> s[1] 'e' >>> s[1] = "a" Traceback (most recent call last): File "", line 1, in s[1] = "a" TypeError: 'str' object does not support item assignment >>> s 'Hello, how are you?' >>> s + s 'Hello, how are you?Hello, how are you?' >>> s[7:16] 'how are y' >>> s[15] 'y' >>> t = "" >>> t '' >>> u = " " >>> u ' ' >>> len(t) 0 >>> len(u) 1 >>> len(s) 19 >>> def capi(s): n = len(s) t = "" for i in range(n): c = s[i].upper() t = t + c return(t) >>> capi("Hello") 'HELLO' >>> capi("Hello you!") 'HELLO YOU!' >>> def lowi(s): n = len(s) t = "" for i in range(n): c = s[i].lower() t = t + c return(t) >>> lowi("Hello! you!") 'hello! you!' >>> s[0] 'H' >>> s[0].isupper() True >>> s[0].islower() False >>> s[1].isupper() False >>> s 'Hello, how are you?' >>> s[5].isupper() False >>> def myfunc(s): n = len(s) t = "" for i in range(n): if s[i].isupper(): c = s[i].lower() else: c = s[i].upper() t = t + c return(t) >>> myfunc("Hello!") 'hELLO!' >>> v = "Hello, my old friend!" >>> myfunc(v) 'hELLO, MY OLD FRIEND!' >>>