looping in python for getting table names
up vote
-2
down vote
favorite
tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)
How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.
python python-3.x
add a comment |
up vote
-2
down vote
favorite
tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)
How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.
python python-3.x
Userangefunctionfor i in range(1, n): ....
– Rakesh
Nov 7 at 7:03
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)
How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.
python python-3.x
tablename1 = GetTbname(1)
tablename2 = GetTbname(2)
tablename3 = GetTbname(3)
.
.
.
.
tablenamen = GetTbname(n)
print(tablename1)
print(tablename2)
print(tablename3)
.
.
.
.
print(tablenamen)
How do I print the above one in looping format so that I can just enter tablename = GetTbname to get the entire table instead of typing entirely manually.
python python-3.x
python python-3.x
edited Nov 7 at 9:10
Mureinik
174k21123191
174k21123191
asked Nov 7 at 7:01
Yadhu
225
225
Userangefunctionfor i in range(1, n): ....
– Rakesh
Nov 7 at 7:03
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09
add a comment |
Userangefunctionfor i in range(1, n): ....
– Rakesh
Nov 7 at 7:03
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09
Use
range function for i in range(1, n): ....– Rakesh
Nov 7 at 7:03
Use
range function for i in range(1, n): ....– Rakesh
Nov 7 at 7:03
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
I'd use a loop and store the names in a list:
num_tables = 100 # or any other value
tables =
for i in range(num_tables):
tables.append(GetTbname(i + 1))
for table in tables:
print(table)
*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
add a comment |
up vote
0
down vote
for i in range(n):
print(GetTbname(i))
In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I'd use a loop and store the names in a list:
num_tables = 100 # or any other value
tables =
for i in range(num_tables):
tables.append(GetTbname(i + 1))
for table in tables:
print(table)
*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
add a comment |
up vote
1
down vote
I'd use a loop and store the names in a list:
num_tables = 100 # or any other value
tables =
for i in range(num_tables):
tables.append(GetTbname(i + 1))
for table in tables:
print(table)
*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
add a comment |
up vote
1
down vote
up vote
1
down vote
I'd use a loop and store the names in a list:
num_tables = 100 # or any other value
tables =
for i in range(num_tables):
tables.append(GetTbname(i + 1))
for table in tables:
print(table)
I'd use a loop and store the names in a list:
num_tables = 100 # or any other value
tables =
for i in range(num_tables):
tables.append(GetTbname(i + 1))
for table in tables:
print(table)
edited Nov 7 at 7:06
answered Nov 7 at 7:05
Mureinik
174k21123191
174k21123191
*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
add a comment |
*tables.append(GetTbname(i + 1))
– Vineeth Sai
Nov 7 at 7:06
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
*
tables.append(GetTbname(i + 1))– Vineeth Sai
Nov 7 at 7:06
*
tables.append(GetTbname(i + 1))– Vineeth Sai
Nov 7 at 7:06
1
1
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
@VineethSai erg, yeah. Stupid typo, thanks for noticing. Edited and fixed.
– Mureinik
Nov 7 at 7:06
add a comment |
up vote
0
down vote
for i in range(n):
print(GetTbname(i))
In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
add a comment |
up vote
0
down vote
for i in range(n):
print(GetTbname(i))
In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
add a comment |
up vote
0
down vote
up vote
0
down vote
for i in range(n):
print(GetTbname(i))
In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.
for i in range(n):
print(GetTbname(i))
In the code above, I assumed there is a list and the GetTbname function returns something based on the index from this list. Here n is the length of the list. I started the loop from 0. You can use range(1,n) to start from 1.
edited Nov 7 at 8:04
SU3
2,49621843
2,49621843
answered Nov 7 at 7:12
Nishil
2238
2238
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
add a comment |
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
1
1
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
Wheres the explanation?
– U9-Forward
Nov 7 at 7:15
1
1
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
I assumed there is a list and the GetTbname function returns something based on the index from this list. here 'n' is the length of the list. Here i started the loop from 0. You can use range(1,n) to start from 1.
– Nishil
Nov 7 at 7:27
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
Please edit the post and paste it in there
– U9-Forward
Nov 7 at 7:28
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184834%2flooping-in-python-for-getting-table-names%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use
rangefunctionfor i in range(1, n): ....– Rakesh
Nov 7 at 7:03
Put your table names into a list instead of separate variables.
– Klaus D.
Nov 7 at 7:09