Empty string: Difference between revisions

From Rosetta Code
Content added Content deleted
(initial draft)
 
(Add Python solution.)
Line 3:
Some languages have syntax or semantics for dealing specifically with empty strings.
 
{{draft task}}
== Task ==
 
The task is to:
Line 12:
 
[[Category:String manipulation]]
 
=={{header|Python}}==
<lang python>s = ''
if not s:
print('String s is empty.')
if s:
print('String s is not empty.')</lang>

Revision as of 21:07, 4 July 2011

Empty string is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Some languages have syntax or semantics for dealing specifically with empty strings.

Empty string is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The task is to:

  • Demonstrate how to assign an empty string to a variable.
  • Demonstrate how to check that a string is empty
  • Demonstrate how to check that a string is not empty.

Python

<lang python>s = if not s:

   print('String s is empty.')

if s:

   print('String s is not empty.')</lang>