table functions
TrainData = {
input= {},
labels = {},
vid={},
size = function() return #input end
}
trainData.input1='test'
print (trainData.size())
why does this print 0?
/r/lua
http://redd.it/53x6mk
TrainData = {
input= {},
labels = {},
vid={},
size = function() return #input end
}
trainData.input1='test'
print (trainData.size())
why does this print 0?
/r/lua
http://redd.it/53x6mk
reddit
table functions • /r/lua
TrainData = { input= {}, labels = {}, vid={}, size = function() return #input end } trainData.input[1]='test' print (trainData.size()) why...
My first Python program :) (I'm hooked)
So, Python was on my list of things to teach myself after I took a C++ course this spring (I regret that, should have taken Python or Java).
So, I am proud of this stupid little dice roller because I evolved it from a basic "This rolls two dice" to "How many do you want to roll?" with input validation. Yay me.
#my first Python program.
#I chose this one to compare to a similar program made
in C++
import random
import time
roll = "yes"
numDice = 0
print("This program will roll as many dice as you need.")
time.sleep(1) #this makes the program pause a bit
print("\nWould you like to roll?")
roll = input()
#input validation to make sure they type yes (y) or no
(no)
while roll != "yes" and roll != "y" and roll != "no" and roll
!= "n":
print("\nType yes (or 'y') or no (or 'n') to roll.")
roll = input()
while roll == "yes" or roll == "y":
print("\nHow many dice do you want to roll?")
numDice = int(input())
print("\nRolling...")
time.sleep(2) #again, a pause
print("\nYou got: ")
for i in range(0, numDice): #this iterates as many times
as the user wants
print(random.randint(1,6)) #generates the random
numbers between 1-6
print("\nRoll again?")
roll = input()
#input validation again
while roll != "yes" and roll != "y" and roll != "no" and
roll != "n":
print("\nType yes or no.")
roll = input()
print("\nThanks for using my program!")
input()
/r/Python
https://redd.it/6hmq58
So, Python was on my list of things to teach myself after I took a C++ course this spring (I regret that, should have taken Python or Java).
So, I am proud of this stupid little dice roller because I evolved it from a basic "This rolls two dice" to "How many do you want to roll?" with input validation. Yay me.
#my first Python program.
#I chose this one to compare to a similar program made
in C++
import random
import time
roll = "yes"
numDice = 0
print("This program will roll as many dice as you need.")
time.sleep(1) #this makes the program pause a bit
print("\nWould you like to roll?")
roll = input()
#input validation to make sure they type yes (y) or no
(no)
while roll != "yes" and roll != "y" and roll != "no" and roll
!= "n":
print("\nType yes (or 'y') or no (or 'n') to roll.")
roll = input()
while roll == "yes" or roll == "y":
print("\nHow many dice do you want to roll?")
numDice = int(input())
print("\nRolling...")
time.sleep(2) #again, a pause
print("\nYou got: ")
for i in range(0, numDice): #this iterates as many times
as the user wants
print(random.randint(1,6)) #generates the random
numbers between 1-6
print("\nRoll again?")
roll = input()
#input validation again
while roll != "yes" and roll != "y" and roll != "no" and
roll != "n":
print("\nType yes or no.")
roll = input()
print("\nThanks for using my program!")
input()
/r/Python
https://redd.it/6hmq58
reddit
My first Python program :) (I'm hooked) • r/Python
So, Python was on my list of things to teach myself after I took a C++ course this spring (I regret that, should have taken Python or Java). So,...