将python转换为lua
我必须将这个python&nbsp“我进行了一段时间的程序转换为LUA程序。我已经完成了一些事情,我似乎无法正确格式化列表,也无法将用户输入的数据通过我的IF-ELSE语句。
该计划应该可以使用户的年龄以及一周的一天,然后输出机票。如果他们的年龄为65岁以上,并且是一周的第二天,则价格为75美元,否则为150美元。
任何帮助将不胜感激
!
python代码
lua代码
week_day = {'Monday = 1', 'Tuesday = 2', 'Wednesday = 3', 'Thursday = 4','Friday = 5', 'Saturday = 6', 'Sunday = 7'}
print("Enter your age:")
local ans = io.read()
print("Enter the day of the week (1-7):")
local wkd = io.read()
if (ans >= 65) and (wkd == 2) then
print("Your fair is $75", "\n")
else
print("Your fair is $150", "\n")
end
I have to convert this Python program I made a while ago into a Lua program. I've done some of it, I just can't seem to format my list correctly or take the data entered by the user and pass it through my if-else statements.
The program is supposed to get the age of the user as well as the day of the week and then output their airfare. If their age is 65 or older and it's the second day of the week, the price is $75 otherwise it is $150.
Any help would be appreciated
Thanks!
Python Code
Lua code
week_day = {'Monday = 1', 'Tuesday = 2', 'Wednesday = 3', 'Thursday = 4','Friday = 5', 'Saturday = 6', 'Sunday = 7'}
print("Enter your age:")
local ans = io.read()
print("Enter the day of the week (1-7):")
local wkd = io.read()
if (ans >= 65) and (wkd == 2) then
print("Your fair is $75", "\n")
else
print("Your fair is $150", "\n")
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查这个项目,我是作者,Poroject还活着,所以请报告任何我的错误,并尽快解决,建议新的A功能,如果可能的话,我也会仔细研究它:
https://github.com/mhadhbixissam/pythoniclua
check this project , i am the author , the poroject is alive so please report any i bug and i fixed as soon as possible , suggest a new a feature also i will look about it if it is possible i add it :
https://github.com/MhadhbiXissam/pythonicLua