从一个函数到另一个函数的移动值-Python

发布于 2025-02-13 14:38:09 字数 452 浏览 1 评论 0原文

我正在学习有关Python的知识,我想将一些值从一个函数转移到另一个功能。

如果您在下面看。我想将用户输入从第一个功能传输,然后自动将其传输到下一个功能以逆转文本。我在这里寻找一些指导。我是编程的新手,所以如果我做了一些愚蠢的事情,请原谅我。

#below函数获取用户输入并存储IT

Def String Rreverse(): sext = input(“您要反向的值是什么?”)

返回sext

sext = string reververs()

#这个函数将字符串输入从上一个函数逆转 def反向(sext): 返回stext [:: - 1]

sext = reververs()

I am learning about python and I want to transfer some value from one function to another.

If you look below. I want to transfer the user input from the first function and then automatically transfer that to the next function to reverse the text. I am looking for some guidance here. I am new to programming so please forgive me if I have done something silly.

#Below function takes the users input and stores it

def stringreverse():
stext = input("What is the value you want to reverse?")

return stext

stext = stringreverse()

#This function reverses the string input from the previous function
def reverse(stext):
return stext[::-1]

stext = reverse()

This is the code online - Repli

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淑女气质 2025-02-20 14:38:09
def stringreverse(stext):
  return stext[::-1]

stringreverse(input("What is the value you want to reverse?"))
def stringreverse(stext):
  return stext[::-1]

stringreverse(input("What is the value you want to reverse?"))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文