String prepend: Difference between revisions
(initial draft task) |
No edit summary |
||
Line 17: | Line 17: | ||
012345678 |
012345678 |
||
</pre> |
</pre> |
||
=={{header| |
=={{header|Python}}== |
||
'''File: String_prepend.py'''<lang python>#!/usr/bin/env python |
'''File: String_prepend.py'''<lang python>#!/usr/bin/env python |
||
# -*- coding: utf-8 -*- # |
# -*- coding: utf-8 -*- # |
||
Line 27: | Line 28: | ||
012345678 |
012345678 |
||
</pre> |
</pre> |
||
=={{header|Wart}}== |
|||
<lang wart>s <- "12345678" |
|||
s <- ("0" + s)</lang> |
Revision as of 06:01, 3 October 2013
You are encouraged to solve this task according to the task description, using any language you may know.
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses
Create a string variable equal to any text value. "Prepend" the string variable with another string literal.
To illustrate the operation, show the content of the variable.
ALGOL 68
File: String_prepend.a68<lang algol68>#!/usr/bin/a68g --script #
- -*- coding: utf-8 -*- #
STRING str := "12345678"; "0" +=: str; print(str)</lang>Output:
012345678
Python
File: String_prepend.py<lang python>#!/usr/bin/env python
- -*- coding: utf-8 -*- #
str = "12345678"; str = "0" + str; # by concatination # print(str)</lang>Output:
012345678
Wart
<lang wart>s <- "12345678" s <- ("0" + s)</lang>