summaryrefslogtreecommitdiff
path: root/gcc/testsuite/python.dg/t_concat_1.py
blob: ecc3dca25706be497a9a33598949268b9291f693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#  Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#
# @Author Carlos Costa – ccosta@bsd.com.br
# @Date 07/09/2010
# @Expected Result: <01234567891011121314151617181920212223242526272829>
#   -Tested against Python Version <2.6.5>

def concat(loop):
  output = ""
  for num in range(loop):
      output += str(num)
  return output

def concat2(loop):
  output = []
  for num in range(loop):
    output.append(str(num))
  return "".join(output)

def concat3(loop):
  return "".join([str(num) for num in range(loop)])


print "will run with", 30, "numbers"
output = concat(30)
print "concat returned", output
output = concat2(30)
print "concat2 returned", output
output = concat3(30)
print "concat3 returned", output