please solve on time chandrayaan 2 in python
Attachments:
Answers
Answered by
4
We have String = "CHANDRAYAAN2".
1. To display the string 'CHAND'.
- String[:5]
2. To display the last four characters.
- String[-4:]
3. To repeat the string two times.
- String*2
4. To display the string 'CADAAN'.
- String[::2]
5. To display the substring 'CHANDRA' in one line and 'YAAN2' in the second.
- print(String[:7], String[7:], sep = "\n")
The act of retrieving a substring from a string is known as string slicing. It is performed using the index values.
Similar questions