Python noob having a little trouble with strings

boB Stepp robertvstepp at gmail.com
Thu Oct 26 22:40:51 EDT 2017


On Thu, Oct 26, 2017 at 9:25 PM,  <randyliu17 at gmail.com> wrote:
> If s1 = "Welcome students", what is the output when you print the following:
>
> 1. s4 = 3 * s1
>
> 2. s1[3 : 6]
>
> 3. 'W' in s1
>
> 4. S1[-1]
>
> 5. S1[:-1]
>
> Any help would be great, thanks!

Why not find out for yourself and print these in the Python
interpreter?  For instance:

> py
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
py3: s1 = "Welcome students"
py3: s4 = 3 * s1
py3: print(s4)
Welcome studentsWelcome studentsWelcome students



-- 
boB



More information about the Python-list mailing list